paulalt
Založený: 16.06.2008
Príspevky: 9
Zaslal: 2008-07-26 05:16
Návrat hore
Odpovedať s citátom
|
jakerbug
,
I've got some time to play around with the add-on since this evening and found out that the script has some limitations (the same thing happens with Karel's solution as well).
Scenario: Let's say, I've got a table with 3 columns: A, B, and C. I do a search on column B, then with the search result in that column, I want to hide column C to make the table more readable.
The problem is, any attempt to hide column C makes search results (on col B) go away.
So, it seems like the script reloads itself every time anything is done with the table.
KarelB
,
Is it possible to make it work, so the search result won't disappear after hiding the column C?
|
KarelB
Založený: 01.06.2007
Príspevky: 24
Zaslal: 2008-07-26 14:17
Návrat hore
Odpovedať s citátom
|
Paulalt,
Both solutions reload the script. My solution when you hit the cross and the checkbox solution when you hit apply. Any search results will be destroyed and the script will reload itself with the columns hidden.
The solutions posted are not meant to keep the state of the form in tact.
My solution is to temporarily remove some columns from wide tables so i can compare values in a row that normally are far away form each other.
The checkbox solution has an other purpose. It is designed to remember the columns you like to show for a different views (scriptfiles) on the same table. It is essentially not designed to temporarily remove columns although you can use it that way.
Remembering the search results and removing columns at the same time is not an easy one ( at least I do not see it).
But the boys from Bill have a program called excel that will do all that:-)
Cheers
Karel
|
jakerbug
Založený: 25.07.2008
Príspevky: 9
Zaslal: 2008-07-26 15:12
Návrat hore
Odpovedať s citátom
|
| KarelB Napísal: |
| The checkbox solution has an other purpose. It is designed to remember the columns you like to show for a different views (scriptfiles) on the same table. It is essentially not designed to temporarily remove columns although you can use it that way. |
Hey KarelB - this is actually how I wanted to use the solution, but I can't figure out how. You obviously noticed right away that it was built for this, so I'm guessing it's not too tough to do.
Referring back to my screen shot a few posts back, I'd like to have links to a "Hotel View," "Golf View," "Restaurant View," etc. in place of the giant "Column Selector" box. There are sets of columns that should be displayed for each of those, and it would much easier to toggle them all on or off at once rather than checking a bunch of checkboxes.
I got it to work by hard coding them in, but I can't figure out how to make it work the "right" way.
|
JammerPro
Založený: 07.12.2006
Príspevky: 33
Zaslal: 2009-10-11 18:02
Návrat hore
Odpovedať s citátom
|
| jakerbug Napísal: |
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.
just wanted to offer another, similar solution to visitors to this post... |
Vang's site is no longer... Is there any way that you would be kind enough to post the code for your special div? It is absolutely brilliant...
Thanks.
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-10-15 07:28
Návrat hore
Odpovedať s citátom
|
The following modifications emulates the screenshot posted above. The first three fields are always included in the form. Placing a checkmark in checkboxes for other fields will include those fields after clicking Next or Previous page or conducting a search ... this is a bit kludgy but it works. Searches within new fields are sticky.
| Kód: |
// Added to the top of the phpMyEdit form:
$col_num = array();
// array of all field names
$fds = array('stock_no', 'year_of_mfg', 'make', 'model', 'bus_type', 'capacity', 'engine', 'brakes', 'miles', 'mileage_comment', 'price', 'sale_price', 'home_page_text', 'long_description', 'special_equipment', 'sold_status', 'hidden', 'deleted', 'updated');
foreach($fds as $key => $val){
if($key < 3 || isset($_REQUEST['fd'][$val])){
$col_num[$key] = 'FL';
}else{
$col_num[$key] = '';
}
} |
I made a copy of the class file and hacked a function as follows:
| Kód: |
function form_end() /* {{{ */
{
global $col_num;
?>
<input type="checkbox" name="fd[stock_no]" id="stock_no" value=""<?php echo !empty($col_num[0]) ? ' checked' : ''; ?> class="forms"> Stock No
<input type="checkbox" name="fd[year_of_mfg]" id="year_of_mfg" value=""<?php echo !empty($col_num[1]) ? ' checked' : ''; ?> class="forms"> Year Of Mfg
<input type="checkbox" name="fd[make]" id="make" value=""<?php echo !empty($col_num[2]) ? ' checked' : ''; ?> class="forms"> Make
<input type="checkbox" name="fd[model]" id="model" value=""<?php echo !empty($col_num[3]) ? ' checked' : ''; ?> class="forms"> Model
<input type="checkbox" name="fd[bus_type]" id="bus_type" value=""<?php echo !empty($col_num[4]) ? ' checked' : ''; ?> class="forms"> Bus Type
<input type="checkbox" name="fd[capacity]" id="capacity" value=""<?php echo !empty($col_num[5]) ? ' checked' : ''; ?> class="forms"> Capacity
<input type="checkbox" name="fd[engine]" id="engine" value=""<?php echo !empty($col_num[6]) ? ' checked' : ''; ?> class="forms"> Engine
<input type="checkbox" name="fd[brakes]" id="brakes" value=""<?php echo !empty($col_num[7]) ? ' checked' : ''; ?> class="forms"> Brakes
<input type="checkbox" name="fd[miles]" id="miles" value=""<?php echo !empty($col_num[8]) ? ' checked' : ''; ?> class="forms"> Miles
<input type="checkbox" name="fd[mileage_comment]" id="mileage_comment" value=""<?php echo !empty($col_num[9]) ? ' checked' : ''; ?> class="forms"> Mileage Comment
<input type="checkbox" name="fd[price]" id="price" value=""<?php echo !empty($col_num[10]) ? ' checked' : ''; ?> class="forms"> Price
<input type="checkbox" name="fd[sale_price]" id="sale_price" value=""<?php echo !empty($col_num[11]) ? ' checked' : ''; ?> class="forms"> Sale Price
<input type="checkbox" name="fd[home_page_text]" id="home_page_text" value=""<?php echo !empty($col_num[12]) ? ' checked' : ''; ?> class="forms"> Home Page Text
<input type="checkbox" name="fd[long_description]" id="long_description" value=""<?php echo !empty($col_num[13]) ? ' checked' : ''; ?> class="forms"> Long Description
<input type="checkbox" name="fd[special_equipment]" id="special_equipment" value=""<?php echo !empty($col_num[14]) ? ' checked' : ''; ?> class="forms"> Special Equipment
<input type="checkbox" name="fd[sold_status]" id="sold_status" value=""<?php echo !empty($col_num[15]) ? ' checked' : ''; ?> class="forms"> Sold Status
<input type="checkbox" name="fd[hidden]" id="hidden" value=""<?php echo !empty($col_num[16]) ? ' checked' : ''; ?> class="forms"> Hidden
<input type="checkbox" name="fd[deleted]" id="deleted" value=""<?php echo !empty($col_num[17]) ? ' checked' : ''; ?> class="forms"> Deleted
<input type="checkbox" name="fd[updated]" id="updated" value=""<?php echo !empty($col_num[18]) ? ' checked' : ''; ?> class="forms"> Updated
<?php
if ($this->display['form']) {
echo '</form>',"\n";
}
} |
phpMyEdit fields with 'options' modified and call to hacked class file:
| Kód: |
$opts['fdd']['stock_no'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Stock No',
'options' => 'ACPVD'.$col_num['0'],
'select' => 'T',
'size' => 30,
'sort' => true
);
$opts['fdd']['year_of_mfg'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '0000',
'help|ACP' => 'Entry Required',
'input' => '',
'maxlen' => 4,
'name' => 'Year Of Mfg',
'options' => 'ACPVD'.$col_num['1'],
'select' => 'T',
'size' => 4,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['make'] = array(
'default' => '',
'help|ACP' => 'Entry Required',
'input' => '',
'maxlen' => 30,
'name' => 'Make',
'options' => 'ACPVD'.$col_num['2'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['model'] = array(
'default' => '',
'help|ACP' => 'Entry Required',
'input' => '',
'maxlen' => 30,
'name' => 'Model',
'options' => 'ACPVD'.$col_num['3'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['bus_type'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => 'Conventional',
'input' => '',
'maxlen' => 12,
'name' => 'Bus Type',
'options' => 'ACPVD'.$col_num['4'],
'select' => 'D',
'sqlw' => 'TRIM("$val_as")',
'values' => array('Conventional','Transit','Mini Bus'),
'sort' => true
);
$opts['fdd']['capacity'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Capacity',
'options' => 'ACPVD'.$col_num['5'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['engine'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Engine',
'options' => 'ACPVD'.$col_num['6'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['brakes'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Brakes',
'options' => 'ACPVD'.$col_num['7'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['miles'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '0',
'input' => '',
'maxlen' => 8,
'name' => 'Miles',
'options' => 'ACPVD'.$col_num['8'],
'select' => 'T',
'size' => 8,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['mileage_comment'] = array(
'default' => '',
'input' => '',
'maxlen' => 30,
'name' => 'Mileage Comment',
'options' => 'ACPVD'.$col_num['9'],
'select' => 'T',
'size' => 30,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['price'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '0.00',
'input' => '',
'maxlen' => 13,
'name' => 'Price',
'options' => 'ACPVD'.$col_num['10'],
'select' => 'T',
'size' => 10,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['sale_price'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '0.00',
'input' => '',
'maxlen' => 13,
'name' => 'Sale Price',
'options' => 'ACPVD'.$col_num['11'],
'select' => 'T',
'size' => 10,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['home_page_text'] = array(
'default' => '',
'input' => '',
'maxlen' => 60,
'name' => 'Home Page Text',
'options' => 'ACPVD'.$col_num['12'],
'select' => 'T',
'size' => 60,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
$opts['fdd']['long_description'] = array(
'default' => '',
'input' => '',
'maxlen' => 65535,
'name' => 'Long Description',
'options' => 'ACPVD'.$col_num['13'],
'select' => 'T',
'sqlw' => 'TRIM("$val_as")',
'strip_tags|FL' => true,
'textarea' => array('rows' => '20', 'cols' => '80'),
'trimlen|FL' => 50,
'sort' => false
);
$opts['fdd']['special_equipment'] = array(
'default' => '',
'input' => '',
'maxlen' => 65535,
'name' => 'Special Equipment',
'options' => 'ACPVD'.$col_num['14'],
'select' => 'T',
'sqlw' => 'TRIM("$val_as")',
'strip_tags|FL' => true,
'textarea' => array('rows' => '20', 'cols' => '80'),
'trimlen|FL' => 50,
'sort' => false
);
$opts['fdd']['sold_status'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '0',
'input' => '',
'maxlen' => 1,
'name' => 'Sold Status',
'options' => 'ACPVD'.$col_num['15'],
'select' => 'D',
'sqlw' => 'TRIM("$val_as")',
'values' => array('0','1'),
'sort' => true
);
$opts['fdd']['hidden'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '',
'input' => '',
'maxlen' => 1,
'name' => 'Hidden',
'options' => 'ACPVD'.$col_num['16'],
'select' => 'D',
'sqlw' => 'TRIM("$val_as")',
'values' => array('0','1'),
'sort' => true
);
$opts['fdd']['deleted'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => '',
'input' => '',
'maxlen' => 1,
'name' => 'Deleted',
'options' => 'ACP',
'select' => 'D',
'sqlw' => 'TRIM("$val_as")',
'values' => array('0','1'),
'sort' => true
);
$opts['fdd']['updated'] = array(
'css' => array('postfix' => 'right-justify'),
'default' => 'CURRENT_TIMESTAMP',
'input' => 'R',
'maxlen' => 19,
'name' => 'Updated',
'options' => 'VD',
'select' => 'T',
'size' => 19,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
require_once('./inc/phpMyEdit.class.buses.php'); // hacked copy of class file
new phpMyEdit($opts); |
|
JammerPro
Založený: 07.12.2006
Príspevky: 33
Zaslal: 2009-10-16 17:51
Návrat hore
Odpovedať s citátom
|
Doug,
That's really fantastic, absolutely brilliant...
Thanks so much for taking the time to post the code.
Works great!!!!!!
Incidentally, where would I place the code in the hacked file to get the checkboxes between the navigation buttons? My checkboxes appear beneath the navigation buttons...
Also, could you let us know what the code is for an "apply button" and a collapsable div like the example on the other page!
I know that's alot to ask, and even if you don't get to it, I am really appreciative of your absoulutely incredible work...
We're not worthy!
All the best.
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2009-10-16 18:04
Návrat hore
Odpovedať s citátom
|
I haven't got a clue about how to implement further changes. Experiment with it. Rename your experimental class files as you try different things, then you can fall back when things don't work out.
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-07-12 07:35
Návrat hore
Odpovedať s citátom
|
| Kód: |
<?php
// common phpMyEdit settings above
// persist display settings for MySQL columns 0 and 5
// $s related to a page id for my CMS and can be removed/ignored
$my0 = get_cgi_var('my0');
if($my0 == ''){ $my0 = 1; } // MySQL column 0 is displayed on form entry
$my5 = get_cgi_var('my5');
if($my5 == ''){ $my5 = 0; } // MySQL column 5 is suppressed on form entry
$opts['cgi']['persist'] = array(
's' => $s,
'my0' => $my0,
'my5' => $my5
);
$opts['fdd']['id'] = array(
'default' => '',
'input' => '',
'maxlen' => 5,
'name' => 'ID',
'select' => 'T',
'size' => 5,
'sort' => true
);
// MySQL column 0
### Set the options based on $my0 ###
$opts['fdd']['id']['options'] = $my0 ? 'ACPVDFL' : 'ACPVD';
$opts['fdd']['snum'] = array(
'default' => '',
'input' => '',
'maxlen' => 5,
'name' => 'Snum',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 5,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
// MySQL column 1
$opts['fdd']['pnum'] = array(
'default' => '',
'input' => '',
'maxlen' => 5,
'name' => 'Pnum',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 5,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
// MySQL column 2
$opts['fdd']['link_text'] = array(
'default' => '',
'input' => '',
'maxlen' => 255,
'name' => 'Link Text',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 80,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
// MySQL column 3
$opts['fdd']['headline'] = array(
'default' => '',
'input' => '',
'maxlen' => 255,
'name' => 'Headline',
'options' => 'ACPVDFL',
'select' => 'T',
'size' => 80,
'sqlw' => 'TRIM("$val_as")',
'sort' => true
);
// MySQL column 4
$opts['fdd']['html_content'] = array(
'default' => '',
'input' => '',
'maxlen' => 65535,
'name' => 'Html Content',
'select' => 'T',
'sqlw' => 'TRIM("$val_as")',
'strip_tags|FL' => true,
'textarea' => array('rows' => 20, 'cols' => 80),
'trimlen|FL' => 50,
'sort' => false
);
// MySQL column 5
### Set the options based on $my5 #############
$opts['fdd']['html_content']['options'] = $my5 ? 'ACPVDFL' : 'ACPVD';
require_once('./inc/phpMyEdit.class.new.php');
new phpMyEdit($opts);
if(empty($_REQUEST['PME_sys_operation'])){
echo "\n\n".'<!-- ### Begin custom buttons ### -->';
function htmlHidden($name, $value)
{
return "\n".'<input type="hidden" name="'.htmlspecialchars($name).'" value="'.htmlspecialchars($value).'" />';
};
function htmlSubmitToggle($name, $value, $sign)
{
return "\n".'<p><input type="submit" name="'.htmlspecialchars($name).'" value="'.($sign ? '[-]' : '[+]').' '.htmlspecialchars($value).'" class="pme-add"/></p>';
};
$buffer_hidden_input = '';
if(isset($_REQUEST['PME_sys_fl'])){
$buffer_hidden_input .= htmlHidden('PME_sys_fl', $_REQUEST['PME_sys_fl']);
}
if(isset($_REQUEST['PME_sys_fm'])){
$buffer_hidden_input .= htmlHidden('PME_sys_fm', $_REQUEST['PME_sys_fm']);
}
if(isset($_REQUEST['PME_sys_qfn'])){
$buffer_hidden_input .= htmlHidden('PME_sys_qfn', $_REQUEST['PME_sys_qfn']);
}
if(isset($_REQUEST['PME_sys_navop'])){
// I would not expect PME_sys_navop to be required,
// but apparently without it, pagination is lost.
// If on page 3 of 6 when disabling/enabling a field the
// user is returned to the first page if PME_sys_navop is not set.
$buffer_hidden_input .= htmlHidden('PME_sys_navop', $_REQUEST['PME_sys_navop']);
}
if(isset($_REQUEST['PME_sys_sfn'][0])){
$buffer_hidden_input .= htmlHidden('PME_sys_sfn[0]', $_REQUEST['PME_sys_sfn'][0]);
}
$buffer_hidden_input .= htmlHidden('s', $s); // CMS page ID (possibly use s for your numeric CMS page ID)
echo "\n\n".'<!-- Button for MySQL column 0 -->';
echo "\n".'<form method="POST" action="'.$opts['self'].'" name="form0" id="form0">';
echo $buffer_hidden_input;
echo htmlHidden('my0', (empty($my0) ? 1 : 0));
echo htmlHidden('my5', $my5);
echo htmlSubmitToggle('my0_submit', 'ID', $my0);
echo "\n".'</form>';
echo "\n\n".'<!-- Button for MySQL column 5 -->';
echo "\n".'<form method="POST" action="'.$opts['self'].'" name="form2" id="form2">';
echo $buffer_hidden_input;
echo htmlHidden('my5', (empty($my5) ? 1 : 0));
echo htmlHidden('my0', $my0);
echo htmlSubmitToggle('my5_submit', 'HTML Content', $my5);
echo "\n".'</form>';
echo "\n\n".'<!-- ### End custom buttons ### -->';
echo "\n\n".'<!-- ### Begin custom Links ### -->';
$buffer_query_string = '';
if(isset($_REQUEST['PME_sys_fl'])){
$buffer_query_string .= '&PME_sys_fl='.$_REQUEST['PME_sys_fl'];
}
if(isset($_REQUEST['PME_sys_fm'])){
$buffer_query_string .= '&PME_sys_fm='.$_REQUEST['PME_sys_fm'];
}
if(isset($_REQUEST['PME_sys_qfn'])){
$buffer_query_string .= '&PME_sys_qfn='.$_REQUEST['PME_sys_qfn'];
}
if(isset($_REQUEST['PME_sys_navop'])){
$buffer_query_string .= '&PME_sys_navop='.$_REQUEST['PME_sys_navop'];
}
if(isset($_REQUEST['PME_sys_sfn'][0])){
$buffer_query_string .= '&PME_sys_sfn[0]='.$_REQUEST['PME_sys_sfn'][0];
}
$buffer_query_string .= '&s='.$s; // CMS page ID (possibly use s for your numeric CMS page ID)
$buffer_query_string = '?'.substr($buffer_query_string, 1);
$buffer_query_string = htmlspecialchars($buffer_query_string);
//echo "\n".'<p>$buffer_query_string = '.$buffer_query_string.'</p>';
function htmlLink($url, $name, $value)
{
return "\n\n".'<p>'.($value ? '[-]' : '[+]').' <a href="'.$url.'">'.htmlspecialchars($name).'</a></p>';
};
$url0 = basename($_SERVER['PHP_SELF']).$buffer_query_string.'&my0='.(empty($my0) ? 1 : 0);
$link0 = htmlLink($url0, 'ID', $my0);
echo $link0;
//echo "\n".'<p>'.htmlspecialchars($link).'</p>';
$url5 = basename($_SERVER['PHP_SELF']).$buffer_query_string.'&my5='.(empty($my5) ? 1 : 0);
$link5 = htmlLink($url5, 'HTML Content', $my5);
echo $link5;
//echo "\n".'<p>'.htmlspecialchars($link).'</p>';
echo "\n\n".'<!-- ### End custom Links ##### -->';
}
?> |
|
Topshed9
Založený: 14.01.2008
Príspevky: 34
Zaslal: 2010-11-14 17:32
Návrat hore
Odpovedať s citátom
|
Unfortunately your link to that page is now dead, but I would love to see the template / code you used for that page of yours with the ability to select / un-select columns If possible Please ...
Regards
Roy..
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-11-14 18:20
Návrat hore
Odpovedať s citátom
|
I hate to sound like a mercenary but see both
http://www.php-html-form.com/sakila/
and
http://www.php-form-generator.com/phpmyedit/generator.php
$39.00 (US) includes several versions including the ones demo'ed at the above links.
|
|
Odoslať novú tému
Odpovedať na tému
Choď na stránku Predchádzajúci 1, 2
|
|