Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Sobota, 28. november 2026
O nás
Magazín
Otvorený softvér
CVS
Služby
Index  »  Projekty  »  phpMyEdit  »  Fórum  »  How to hide a column in the table during a session?

phpMyEdit Configuration     How to hide a column in the table during a session?
Odoslať novú tému   Odpovedať na tému   Choď na stránku 1, 2  Ďalší  
 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-06-16 20:08
Návrat hore  Odpovedať s citátom     

I've created my_table file through phpMyEdit code generator. my_table has 5 columns (x, y, z, w, d). I would like to hide columns: z, w, and d, only during a session (temporarily).
How can I do that after the my_table has been called?

 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2008-07-08 02:29
Návrat hore  Odpovedať s citátom     

if you comment these out (using /* ... */) they will not be displayed.

have a look at display options (hiding only in list view, or so)

 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-09 02:39
Návrat hore  Odpovedať s citátom     

Hi Michal,

First off, thanks for responding to my question. I know about that option you have mentioned. Unfortunately, that would require - every time I want to hide a column in the table - changing the script. Not particularly the easiest way if you ask me.

I thought of an easier way to do that through the script's interface. That would be a great feature!

 
michal     Založený: 17.06.2003   Príspevky: 537   Bydlisko: Slovakia
Príspevok Zaslal: 2008-07-09 09:07
Návrat hore  Odpovedať s citátom     

there is no built in feature like that

 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-11 01:08
Návrat hore  Odpovedať s citátom     

I'd like to hide columns without any conditional statements.

 
KarelB     Založený: 01.06.2007   Príspevky: 24  
Príspevok Zaslal: 2008-07-22 21:08
Návrat hore  Odpovedať s citátom     

Everything is possible with some imagination and depending on your php/html/css skills.

Although i have not tested this i could think of something along the following lines.
Maybe you could put some html code in the description field like <a href="myself.php?colA=1">X</a>
then around your column opt array have an if statement:
if (! $_GET['colA']) {
$opts['ffd']['colA']=...
...
}

something like that,maybe?
Karel

 
KarelB     Založený: 01.06.2007   Príspevky: 24  
Príspevok Zaslal: 2008-07-22 21:59
Návrat hore  Odpovedať s citátom     

LS

I got intrigued by my own solution and tested it.
Put in the description field the following code:
Kód:

</a><a href="myself.php?colA=1">X


This is no typo to get the closing </a> tag first.
Works like a charm!

Instead of the X you can put an nice image with a cross or something.
Have fun
KArel

 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-23 03:04
Návrat hore  Odpovedať s citátom     

Hi KarelB,


That's a good news. Would you be so kind and help me a little bit? My skills fall short of the required minimum to make your concept work. My script is below. I'd appreciate your help very much.


Kód:

<style type="text/css">
        hr.pme-hr            { border: 0px solid; padding: 0px; margin: 0px; border-top-width: 1px; height: 1px; }
        table.pme-main       { border: #004d9c 1px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
        table.pme-navigation { border: #004d9c 0px solid; border-collapse: collapse; border-spacing: 0px; width: 100%; }
        td.pme-navigation-0, td.pme-navigation-1 { white-space: nowrap; }
        th.pme-header        { border: #004d9c 1px solid; padding: 4px; background: #add8e6; }
        td.pme-key-0, td.pme-value-0, td.pme-help-0, td.pme-navigation-0, td.pme-cell-0,
        td.pme-key-1, td.pme-value-1, td.pme-help-0, td.pme-navigation-1, td.pme-cell-1,
        td.pme-sortinfo, td.pme-filter { border: #004d9c 1px solid; padding: 3px; }
        td.pme-buttons { text-align: left;   }
        td.pme-message { text-align: center; }
        td.pme-stats   { text-align: right;  }
</style><?php


// MySQL host name, user name, password, database, and table
$opts['hn'] = 'xx';
$opts['un'] = 'xx';
$opts['pw'] = 'xx';
$opts['db'] = 'xx';
$opts['tb'] = 'xx';

// Name of field which is the unique key
$opts['key'] = 'id';

// Type of key field (int/real/string/date etc.)
$opts['key_type'] = 'int';

// Sorting field(s)
$opts['sort_field'] = array('id');

// Number of records to display on the screen
// Value of -1 lists all records in a table
$opts['inc'] = 15;

// Options you wish to give the users
// A - add,  C - change, P - copy, V - view, D - delete,
// F - filter, I - initial sort suppressed
$opts['options'] = 'ACPVDF';

// Number of lines to display on multiple selection filters
$opts['multiple'] = '4';

// Navigation style: B - buttons (default), T - text links, G - graphic links
// Buttons position: U - up, D - down (default)
$opts['navigation'] = 'DB';

// Display special page elements
$opts['display'] = array(
        'form'  => true,
        'query' => true,
        'sort'  => true,
        'time'  => true,
        'tabs'  => true
);

// Set default prefixes for variables
$opts['js']['prefix']               = 'PME_js_';
$opts['dhtml']['prefix']            = 'PME_dhtml_';
$opts['cgi']['prefix']['operation'] = 'PME_op_';
$opts['cgi']['prefix']['sys']       = 'PME_sys_';
$opts['cgi']['prefix']['data']      = 'PME_data_';

/* Get the user's default language and use it if possible or you can
   specify particular one you want to use. Refer to official documentation
   for list of available languages. */
$opts['language'] = $_SERVER['HTTP_ACCEPT_LANGUAGE'] . '-UTF8';

/* Table-level filter capability. If set, it is included in the WHERE clause
   of any generated SELECT statement in SQL query. This gives you ability to
   work only with subset of data from table.

$opts['filters'] = "column1 like '%11%' AND column2<17";
$opts['filters'] = "section_id = 9";
$opts['filters'] = "PMEtable0.sessions_count > 200";
*/


$opts['fdd']['id'] = array(
  'name'     => 'ID',
  'select'   => 'T',
  'options'  => 'AVCPDR', // auto increment
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['file'] = array(
  'name'     => 'File',
  'select'   => 'T',
  'maxlen'   => 255,
  'sort'     => true
);
$opts['fdd']['catalog'] = array(
  'name'     => 'Catalog',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['album'] = array(
  'name'     => 'Album',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['year'] = array(
  'name'     => 'Year',
  'select'   => 'T',
  'maxlen'   => 4,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['artist'] = array(
  'name'     => 'Artist',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['title'] = array(
  'name'     => 'Title',
  'select'   => 'T',
  'maxlen'   => 255,
  'sort'     => true
);
$opts['fdd']['bitrate'] = array(
  'name'     => 'Bitrate',
  'select'   => 'T',
  'maxlen'   => 8,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['rate'] = array(
  'name'     => 'Rate',
  'select'   => 'T',
  'maxlen'   => 8,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['mode'] = array(
  'name'     => 'Mode',
  'select'   => 'T',
  'maxlen'   => 3,
  'values'   => array(
                  "abr",
                  "vbr",
                  "cbr"),
  'sort'     => true
);
$opts['fdd']['size'] = array(
  'name'     => 'Size',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['time'] = array(
  'name'     => 'Time',
  'select'   => 'T',
  'maxlen'   => 5,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['track'] = array(
  'name'     => 'Track',
  'select'   => 'T',
  'maxlen'   => 5,
  'sort'     => true
);
$opts['fdd']['genre'] = array(
  'name'     => 'Genre',
  'select'   => 'T',
  'maxlen'   => 11,
  'sort'     => true
);
$opts['fdd']['played'] = array(
  'name'     => 'Played',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['enabled'] = array(
  'name'     => 'Enabled',
  'select'   => 'T',
  'maxlen'   => 1,
  'default'  => '1',
  'sort'     => true
);
$opts['fdd']['update_time'] = array(
  'name'     => 'Update time',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['addition_time'] = array(
  'name'     => 'Addition time',
  'select'   => 'T',
  'maxlen'   => 11,
  'default'  => '0',
  'sort'     => true
);
$opts['fdd']['hash'] = array(
  'name'     => 'Hash',
  'select'   => 'T',
  'maxlen'   => 64,
  'sort'     => true
);

// Now important call to phpMyEdit
require_once 'phpMyEdit.class.php';
new phpMyEdit($opts);

?>


 
KarelB     Založený: 01.06.2007   Príspevky: 24  
Príspevok Zaslal: 2008-07-23 08:17
Návrat hore  Odpovedať s citátom     

Hi Paulalt,

The principle is the same for every field that you need to hide. Following is the code for your first two fields:
Kód:

if (! $_GET['colA']) {
  $opts['fdd']['file'] = array(
    'name'     => 'File </a><a href="myself.php?colA=1">X',
    'select'   => 'T',
    'maxlen'   => 255,
    'sort'     => true
  );
}

if (! $_GET['colB']) {
  $opts['fdd']['catalog'] = array(
    'name'     => 'Catalog </a><a href="myself.php?colB=1">X',
    'select'   => 'T',
    'maxlen'   => 11,
    'default'  => '0',
    'sort'     => true
  );
}

Don't foraget to replace the myself.php with your scriptname or use the global $_SERVER variable for the scriptname.

It requires some editing or you can modify the setup script to output this automatically.

Cheers
KArel

 
KarelB     Založený: 01.06.2007   Príspevky: 24  
Príspevok Zaslal: 2008-07-23 20:37
Návrat hore  Odpovedať s citátom     

And this is the final solution that I now am going to implement in my own application (although i will use an image instead of the "X")

Replace the line:
Kód:

'name'     => 'File </a><a href="myself.php?colA=1">X',


with the following code:

Kód:

'name'     => "File </a>&nbsp;<a href=\"".$_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']."&colA=1\">X"


This allows you to hide multiple rows (one at the time). To get all the columns back you have to restart the script.
Have fun
Karel

 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-24 01:50
Návrat hore  Odpovedať s citátom     

Hi KarelB,

Hands down, you are a genius! You made my day! It works great! I wish it were a built-in feature like that in the script's generator.

Thank you very much!

 
jakerbug     Založený: 25.07.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-25 19:39
Návrat hore  Odpovedať s citátom     

did you know about this little nugget:
http://www.hq.ro/vang/phpmyedit/

i tried the solution here and while it is very creative and works well, the solution at that website allows you to toggle columns on and off without reloading.

i wrapped mine in a nice little hide/show DIV and I'm very pleased with the results.

Image

just wanted to offer another, similar solution to visitors to this post...

 
paulalt     Založený: 16.06.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-25 21:44
Návrat hore  Odpovedať s citátom     

Hi jakerbug,

This is all I needed from the script (which I really like). Works like a charm. Thank you.

BTW, you've got a nice template. Where did you get it?

 
KarelB     Založený: 01.06.2007   Príspevky: 24  
Príspevok Zaslal: 2008-07-25 21:44
Návrat hore  Odpovedať s citátom     

Thanks for sharing this nice solution and it pointed me to a way to avoid the less elegant edits for the if statements. But the posted solution need some work IMHO.

1 Instead of setting the options hard to 'ACFVPD' it should remove the option L from the original setting.
(php function str_replace) and this is what i am going to use to hide my columns.
2. When building the checkbox array it should check if the L option is set. If not do not make a checkbox. Otherwise hidden en dummy fields will show up.
3. I can see the reason for assigning them to session variables but in my case this is not desirable.

My 2 cents.

Karel

 
jakerbug     Založený: 25.07.2008   Príspevky: 9  
Príspevok Zaslal: 2008-07-25 22:36
Návrat hore  Odpovedať s citátom     

hi paulalt - i got the css from this post: http://opensource.platon.sk/forum/projects/viewtopic.php?t=755

then i spent some time playing with the colors, borders, padding, etc. you can download it from http://www.cocre01.com/personal/dbstyle1.css if you really like it, but i can't guarantee i didn't mess something up while i was tinkering. it's customized to my implementation specifically and might not work as well for you...

karelb - i'd love to see what you come up with. you're obviously very good with php (which i'm not) and I agree that your suggestions would make this solution even better.

glad i could point you in this direction... hope you are able to get it working as you describe. if you do another post here would be nice ;)

 
Odoslať novú tému   Odpovedať na tému   Choď na stránku 1, 2  Ďalší  

Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok · Odkazový formulár · Prihláška
Upozorniť na chybu na PLATON.SK webstránke · Podmienky použitia · Ochrana osobných údajov