Hi Tony – tested and all works perfectly so it works as it did before. Nice. I also used the .min.js version and all the other functions works perfectly too like the filters and excel/pdf buttons are all working.
Thank you!
I have added a video here showing how this is behaving. Might well be something to do with the set-up I have but not sure.
You will need to use a PW of TONYJQGRID
Cheers, Chris.
Hello – so when I use the responsive=>true with 100% I do get the button available. Unfortunately when I click on the button I see the menu of options and the then it reloads the form , so not getting a chance to click on the menu options. Not sure why as yet.
The strange thing is that whether I use 100% and responsive or specify the 800 the grid always gets resized the same size and with 800 being used I see the normal icons and the with 100% and responsive I see the button (even thought it is not working on my example) so I guess the calculation or logic to determine if there is not enough room my be a bit off. The grid size after it gets resized on a normal laptop screen is 400px width.
Not sure of my display problems on the button have anything to do with the CSS I am using, but if you can point me in the right direction as I am using the CSS from the trirand directory structure?
/css/trirand/ui.jqgrid.css”
/css//ui.multiselect.css”
Where is the latest CSS held and language?
Thanks for your help Tony.
Hi Tony, by the way I have now changed all from 100% to 800 and it works fine, so there is no great urgency on this one, but I guess it would be nice to know why it is acting strangely based on width.
We also resize the grid once in anyway as it is dependant on the browser width and height, so it is odd as the size of the grid ends up the same based on this whether I set the PHP to 100% or 800, but it decides not to include the icons in the left pager.
As I said if you set the width so something small like 200 or 300 it decides not to include the icons also.
Hope this all helps, but if you need anything else from me let me know.
OK – I have created a test file and can replicate it. The issue seems to be related to the width set in gridoptions. If I use a width of 100% (my normal setting) then it will not show the icons if I hide the TagID field. If I set it to say 600 it works! If I set it to 200 it does not work.
Here is the PHP file and services it calls. I have left the width at 300 so you can see it not displaying…
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
<HTML> <head> <!-- Contact Form CSS files --> <link type='text/css' href='stylesheet/basic.css' rel='stylesheet' media='screen' /> <link type='text/css' href='stylesheet/jquery-ui/jquery-ui.css' rel='stylesheet' media='screen' /> <script src="javascript/jquery-1.11.0.min.js" language="javascript" type="text/javascript"></script> <script src="javascript/jquery-ui/1.10.4/jquery-ui.min.js"></script> <script src="gridChartFramework/js/trirand/jquery.jqGrid.js" type="text/javascript"></script> <script src="gridChartFramework/js/trirand/i18n/grid.locale-en.js" type="text/javascript"></script> <script type="text/javascript">$.jgrid.no_legacy_api = true;</script> <!-- jquery.jqgrid CSS --> <link rel="stylesheet" type="text/css" media="screen" href="gridChartFramework/css/trirand/ui.jqgrid.css" /> <link rel="stylesheet" type="text/css" media="screen" href="gridChartFramework/css//ui.multiselect.css" /> </head> <body> <?php $_SESSION['gridName'] = pathinfo($_SERVER['PHP_SELF'], PATHINFO_FILENAME);?> <?php $_SESSION['tagRef'] = 4; $_SESSION['grid_query']="select note_date,notes,ID,TagID FROM tag_notes WHERE TagID = 4"; include_once './services/jqgrid/new_tag_notes_grid.php'; ?> </body> </HTML> |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
<?php if (!isset($_SESSION['grid_query'])) { session_start(); } $editable = true; include __DIR__ . '/../../include/jq-config.php'; include __DIR__ . '/../../include/jq-config-calendar.php'; $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); $conn->query("SET NAMES utf8"); // Create the jqGrid instance $conn->setAttribute( PDO::ATTR_EMULATE_PREPARES, false ); $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $grid = new jqGridRender($conn); $grid->exportfile = 'ZipNFC_tag_notes_'.$_SESSION['tagRef'].'.xls'; // Set the SQL Data source $grid->serialKey = true; $grid->debug = true; $grid->setPrimaryKeyId('ID'); $grid->SelectCommand = $_SESSION['grid_query']; $grid->dataType = 'json'; // Let the grid create the model $grid->table = 'tag_notes'; // define the tabel used for deleting $grid->setColModel(); $grid->setGridOptions(array( "rowNum"=>20, "sortname"=>"note_date", "sortorder"=>"desc", "hoverrows"=>true, "shrinktofit"=>true, "width"=>"300" )); $grid->setDatepicker('note_date', array("buttonIcon"=>true,"dateFormat"=>'dd-mm-yy'), true, false); $grid->datearray = array("note_date"); $grid->setUserDate("d-m-Y"); $grid->setDbDate("Y-m-d"); $grid->toolbarfilter = true; $grid->navigator = true; $grid->setNavOptions('navigator', array("excel"=>true,"pdf"=>false, "add"=>$editable,"edit"=>$editable,"del"=>$editable,"view"=>false,"cloneToTop"=>true)); $grid->setUrl("./services/jqgrid/new_tag_notes_grid.php"); $grid->setColProperty("ID", array("hidden"=>true)); $grid->setColProperty("TagID", array("hidden"=>true)); $grid->setColProperty("TagID", array( "editrules"=>array("edithidden"=>false), "editoptions"=>array("defaultValue"=>$_SESSION['tagRef'])) ); $grid->setColProperty("note_date", array("label"=>'Date',"width"=>'50',"formatter"=>'date', "formatoptions"=>array('srcformat'=>'Y-m-d','newformat'=>'d-m-y'))); $grid->setColProperty("notes", array("label"=>'Notes',"edittype"=>'textarea',"editoptions"=>array("rows"=>10,"cols"=>40))); $grid->setNavOptions('edit',array("width"=>400,"height"=>250,"dataheight"=>'180')); $grid->setNavOptions('add',array("width"=>400,"height"=>250,"dataheight"=>'180')); $grid->renderGrid('#action_grid','#action_pager',true, null, null, true,true); $conn = null; ?> |
Working on a test set of files, but to start with here is the script created when the TagID column is hidden and you do not see the icons:
|
1 2 3 4 5 6 7 8 9 10 11 |
jQuery(document).ready(function($) {jQuery('#action_grid').jqGrid({"hoverrows":true,"viewrecords":true,"jsonReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"xmlReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"gridview":true,"rowNum":20,"search":false,"sortname":"note_date","sortorder":"desc","shrinkToFit":true,"width":"100%","url":".\/services\/jqgrid\/new_tag_notes_grid.php","editurl":".\/services\/jqgrid\/new_tag_notes_grid.php","cellurl":".\/services\/jqgrid\/new_tag_notes_grid.php","datatype":"json","colModel":[{"name":"note_date","index":"note_date","sorttype":"date","editoptions":{"dataInit":function(el){setTimeout(function(){if(jQuery.ui) { if(jQuery.ui.datepicker) { jQuery(el).after('<button>Calendar</button>').next().button({icons:{primary: 'ui-icon-calendar'}, text:false}).css({'font-size':'75%'}).click(function(e){jQuery(el).datepicker('show');return false;});jQuery(el).datepicker({"disabled":false,"dateFormat":"dd-mm-yy"});jQuery('.ui-datepicker').css({'font-size':'75%'});} }},100);}},"label":"Date","width":"50","formatter":"date","formatoptions":{"srcformat":"Y-m-d","newformat":"d-m-y"},"editable":true},{"name":"notes","index":"notes","sorttype":"string","label":"Notes","edittype":"textarea","editoptions":{"rows":10,"cols":40},"editable":true},{"name":"ID","index":"ID","sorttype":"int","key":true,"hidden":true,"editable":true},{"name":"TagID","index":"TagID","sorttype":"int","hidden":true,"editrules":{"edithidden":false},"editoptions":{"defaultValue":"5"},"editable":true}],"postData":{"oper":"grid"},"prmNames":{"page":"page","rows":"rows","sort":"sidx","order":"sord","search":"_search","nd":"nd","id":"ID","filter":"filters","searchField":"searchField","searchOper":"searchOper","searchString":"searchString","oper":"oper","query":"grid","addoper":"add","editoper":"edit","deloper":"del","excel":"excel","subgrid":"subgrid","totalrows":"totalrows","autocomplete":"autocmpl"},"loadError":function(xhr,status, err){ try {jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,' <div class="ui-state-error">'+ xhr.responseText +'</div> ', jQuery.jgrid.edit.bClose,{buttonalign:'right'});} catch(e) { alert(xhr.responseText);} },"pager":"#action_pager"});jQuery('#action_grid').jqGrid('navGrid','#action_pager',{"edit":true,"add":true,"del":true,"search":true,"refresh":true,"view":false,"excel":true,"pdf":false,"csv":false,"columns":false,"cloneToTop":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":"180","errorTextFormat":function(r){ return r.responseText;},"width":400,"height":250},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":"180","errorTextFormat":function(r){ return r.responseText;},"width":400,"height":250},{"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"closeAfterSearch":true,"multipleSearch":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150});jQuery('#action_grid').jqGrid('navButtonAdd','#action_pager',{id:'action_pager_excel', caption:'',title:'Export To Excel',onClickButton : function(e) { try { jQuery("#action_grid").jqGrid('excelExport',{tag:'excel', url:'./services/jqgrid/new_tag_notes_grid.php'}); } catch (e) { window.location= './services/jqgrid/new_tag_notes_grid.php?oper=excel'; } },buttonicon:'ui-icon-newwin'});jQuery('#action_grid').jqGrid('filterToolbar',{"stringResult":true}); }); |
AND here is the script generated when the TagID is not hidden and you see the icons:
|
1 2 3 4 5 6 7 8 9 10 11 |
jQuery(document).ready(function($) {jQuery('#action_grid').jqGrid({"hoverrows":true,"viewrecords":true,"jsonReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"xmlReader":{"repeatitems":false,"subgrid":{"repeatitems":false}},"gridview":true,"rowNum":20,"search":false,"sortname":"note_date","sortorder":"desc","shrinkToFit":true,"width":"100%","url":".\/services\/jqgrid\/new_tag_notes_grid.php","editurl":".\/services\/jqgrid\/new_tag_notes_grid.php","cellurl":".\/services\/jqgrid\/new_tag_notes_grid.php","datatype":"json","colModel":[{"name":"note_date","index":"note_date","sorttype":"date","editoptions":{"dataInit":function(el){setTimeout(function(){if(jQuery.ui) { if(jQuery.ui.datepicker) { jQuery(el).after('<button>Calendar</button>').next().button({icons:{primary: 'ui-icon-calendar'}, text:false}).css({'font-size':'75%'}).click(function(e){jQuery(el).datepicker('show');return false;});jQuery(el).datepicker({"disabled":false,"dateFormat":"dd-mm-yy"});jQuery('.ui-datepicker').css({'font-size':'75%'});} }},100);}},"label":"Date","width":"50","formatter":"date","formatoptions":{"srcformat":"Y-m-d","newformat":"d-m-y"},"editable":true},{"name":"notes","index":"notes","sorttype":"string","label":"Notes","edittype":"textarea","editoptions":{"rows":10,"cols":40},"editable":true},{"name":"ID","index":"ID","sorttype":"int","key":true,"hidden":true,"editable":true},{"name":"TagID","index":"TagID","sorttype":"int","editrules":{"edithidden":false},"editoptions":{"defaultValue":"5"},"editable":true}],"postData":{"oper":"grid"},"prmNames":{"page":"page","rows":"rows","sort":"sidx","order":"sord","search":"_search","nd":"nd","id":"ID","filter":"filters","searchField":"searchField","searchOper":"searchOper","searchString":"searchString","oper":"oper","query":"grid","addoper":"add","editoper":"edit","deloper":"del","excel":"excel","subgrid":"subgrid","totalrows":"totalrows","autocomplete":"autocmpl"},"loadError":function(xhr,status, err){ try {jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,' <div class="ui-state-error">'+ xhr.responseText +'</div> ', jQuery.jgrid.edit.bClose,{buttonalign:'right'});} catch(e) { alert(xhr.responseText);} },"pager":"#action_pager"});jQuery('#action_grid').jqGrid('navGrid','#action_pager',{"edit":true,"add":true,"del":true,"search":true,"refresh":true,"view":false,"excel":true,"pdf":false,"csv":false,"columns":false,"cloneToTop":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":"180","errorTextFormat":function(r){ return r.responseText;},"width":400,"height":250},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":"180","errorTextFormat":function(r){ return r.responseText;},"width":400,"height":250},{"errorTextFormat":function(r){ return r.responseText;}},{"drag":true,"closeAfterSearch":true,"multipleSearch":true},{"drag":true,"resize":true,"closeOnEscape":true,"dataheight":150});jQuery('#action_grid').jqGrid('navButtonAdd','#action_pager',{id:'action_pager_excel', caption:'',title:'Export To Excel',onClickButton : function(e) { try { jQuery("#action_grid").jqGrid('excelExport',{tag:'excel', url:'./services/jqgrid/new_tag_notes_grid.php'}); } catch (e) { window.location= './services/jqgrid/new_tag_notes_grid.php?oper=excel'; } },buttonicon:'ui-icon-newwin'});jQuery('#action_grid').jqGrid('filterToolbar',{"stringResult":true}); }); |
Here are some visuals:
Grid when TagId is hidden – no icons!
![]()
Grid when TagID is not hidden – icons appear!
![]()
Ignore that last suggestion on my note – too much testing and not realising what I am seeing!!
All good and working a treat.
Hi Tony – loaded and tested – that works perfectly. Thanks again for fixing so quickly.
OK – this is a suggestion to consider for the future or maybe you can do it and I have not figured out, but it would be useful to save everything apart from the data as when I load I want the grid to the same state, but reload the data afresh. At the moment I am loading the state which brings back the data being stored and then triggering a reload to get the latest data. I was thinking something like a storeGridData option as an example to compliment the storeNavOptions as this would help with local storage being used when I do not necessarily need it.
If you have any bright ideas that would help, please let me know, but I am very happy as it is all working.
Thanks again.
Hi Tony, one thing I have noticed tonight whilst testing is that frozen columns are not brought back when loadingState. I only have one place in the system we use this and although not ideal it is not a show stopper. If you get a chance to include that would be great.
But I have to say it is all working really well in all our systems now and they have gone live using the new version of the grid and the load and save state!
Hi – I will look at firebug, but did not have much luck with it last time I looked. I think you have to type in javascript commands to clear the local storage, but did not seem to work. If there is anyone out there that has a clue to this it would be appreciated, but if I find the answer I will post here. I believe if you clear your cookies it will clear it, but not sure yet – that seems a bit drastic.
Regarding the other methods that would be perfect. In the meantime I will probably add a reset function to clear local storage for the page. As I load it by default on the page load and save everytime you leave it really needs to give the user a quick way to remove all filters and sorts to go back to default.
Thanks for all your help Tony – it really is appreciated.
By the way will you be release some sort of official patch release with this code in?
Hi Tony – that all works perfectly – thank you so much. I can now proceed and upgrade all my software and start to use some of your new features. Excellent.
Not related as such, but in chrome I can clear the local storage through the development tools. Have you found any way of doing it in Firefox as it does not have the same dev tools?
Cheers, Chris.
Hello Tony. So the great news is that after using your jquery.jqGrid.js code from github I am now saving the excel and pdf buttons – fantastic!
The bad news and quite sure this is something I have not done right, but the filter is still missing even though applied. So to be clear the filter is saved, but not being redisplayed in the top of the column so you know what you have filtered on.
Let me know if I need to download something else other than jquery.jqGrid.js or if there is anything else I can provide to debug why this is not working for me.
Thank you so much for cracking the custom buttons!
Thanks Tony… good to see.. Cheers Chris.
OK – appreciated. I can see you save whether excel and PDF are true or false in the local store so half way there, but I tried to work out how I could get them back myself, but my javascript skills are not that good!
Till next week! Have a great weekend.
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top