Hmmm… seems like an oversight to me as if the grid does not look the same as before then you are not saving state:-) Also Excel and PDF are set via the same setNavOptions.
Whilst you are looking at this can you recommend a neat way of adding this every time when being loaded from state – is there some javascript I can add that will put the excel export and PDF buttons back? Obviously the excel and pdf code is in the PHP file still to be executed when the Excel and PDF export are clicked? We have the export excel on every grid and export to PDF on some, but happy to just have it on everything and make sure the PDF code is in all PHP.
I have been waiting for the sticky feature for so long and you are so close to having a 100% finished feature – shame to not get it complete:-)
Cheers, Chris.
OK – I found in the comments of the code that you have to tell it to save the navigation settings, so I have used the storeNavOptions=>true in the PHP file and now the Edit, Add, Delete, Refresh options to come back when I loadState.
BUT – unless there is another setting required it is not reinstating the Export to Excel and Export to PDF for some weird reason.
Help appreciated… feel like I am getting closer!
Hello Tony – this is all working perfectly now, but have found a couple of gremlins, one you have already said is an issue on another post where when you saveState and loadState it applies the filters, but does not populate the filter boxes with the filter values so you do not know as a users what filters have been applied where.
But I have found another one with regard to the Navigation options set by:
$grid->setNavOptions(‘navigator’, array(“excel”=>true,”pdf”=>true, “add”=>false,”edit”=>false,”del”=>false,”view”=>true,”cloneToTop”=>true));
When you load the grid with no save state they appear perfectly, but soon as you saveState and then load you lose them all….
I am really hoping it should be OK and I am doing something wrong, but after a few hours of trying I thought I would ask to stop beating myself up!
Any help appreciated as I probably can live with the filters, but losing the option to Export to excel and PDF etc is not an option.
Some background information:
|
1 2 3 |
{"url":"./services/jqgrid/analysis_grid.php","height":445,"page":1,"rowNum":10,"rowTotal":null,"records":2,"pager":"#pager","pgbuttons":true,"pginput":true,"colModel":[{"name":"Detail","editable":false,"sortable":false,"resizable":false,"fixed":true,"width":60,"search":false,"align":"center","formatter":"function MyFormatter(cellValue, options, rowdata)\n{\n\treturn \"<a href="./analysis_tag_detail.php?det_type=tag&tag_id=\&quot;+rowdata["><img title="Click to view detail" src="./images/view_detail_icon.png" alt="" width="25" height="25" /></a>\";\n}","title":true,"lso":"","hidden":false,"widthOrg":60,"stype":"text"},{"name":"TAGID","index":"TAGID","sorttype":"int","key":true,"label":"TagID","align":"right","width":138,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":138,"resizable":true,"sortable":true,"search":true,"stype":"text"},{"name":"tag_name","index":"tag_name","sorttype":"string","label":"Name","align":"left","width":413,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":413,"resizable":true,"sortable":true,"search":true,"stype":"text"},{"name":"QR","index":"QR","sorttype":"numeric","label":"QR","align":"right","width":138,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":138,"resizable":true,"sortable":true,"search":true,"stype":"text"},{"name":"NFC","index":"NFC","sorttype":"numeric","label":"NFC","align":"right","width":138,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":138,"resizable":true,"sortable":true,"search":true,"stype":"text"},{"name":"iB","index":"iB","sorttype":"numeric","label":"iBeacon","align":"right","width":138,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":138,"resizable":true,"sortable":true,"search":true,"stype":"text"},{"name":"Total","index":"Total","sorttype":"numeric","label":"Total","align":"right","width":135,"editable":true,"title":true,"lso":"","hidden":false,"widthOrg":135,"resizable":true,"sortable":true,"search":true,"stype":"text"}],"rowList":[10,20,30,50],"colNames":["Detail","TagID","Name","QR","NFC","iBeacon","Total"],"sortorder":"desc","sortname":"Total","datatype":"json","mtype":"GET","altRows":false,"selarrrow":[],"savedRow":[],"shrinkToFit":true,"xmlReader":{"root":"rows","row":"row","page":"rows>page","total":"rows>total","records":"rows>records","repeatitems":false,"cell":"cell","id":"[id]","userdata":"userdata","subgrid":{"root":"rows","row":"row","repeatitems":false,"cell":"cell"}},"jsonReader":{"root":"rows","page":"page","total":"total","records":"records","repeatitems":false,"cell":"cell","id":"id","userdata":"userdata","subgrid":{"root":"rows","repeatitems":false,"cell":"cell"}},"subGrid":false,"subGridModel":[],"reccount":2,"lastpage":1,"lastsort":6,"selrow":null,"beforeSelectRow":null,"onSelectRow":null,"onSortCol":null,"ondblClickRow":null,"onRightClickRow":null,"onPaging":null,"onSelectAll":null,"onInitGrid":null,"loadComplete":null,"gridComplete":null,"loadError":"function (xhr,status, err){ try {jQuery.jgrid.info_dialog(jQuery.jgrid.errors.errcap,' <div class="\&quot;ui-state-error\&quot;">'+ xhr.responseText +'</div> ', jQuery.jgrid.edit.bClose,{buttonalign:'right'});} catch(e) { alert(xhr.responseText);} }","loadBeforeSend":null,"afterInsertRow":null,"beforeRequest":null,"beforeProcessing":null,"onHeaderClick":null,"viewrecords":true,"loadonce":false,"multiselect":false,"multikey":false,"editurl":"./services/jqgrid/analysis_grid.php","search":false,"caption":"","hidegrid":true,"hiddengrid":false,"postData":{"oper":"grid","_search":false,"nd":1439382129238,"rows":10,"page":1,"sidx":"Total","sord":"desc"},"userData":{},"treeGrid":false,"treeGridModel":"nested","treeReader":{},"treeANode":-1,"ExpandColumn":null,"tree_root_level":0,"prmNames":{"page":"page","rows":"rows","sort":"sidx","order":"sord","search":"_search","nd":"nd","id":"id","oper":"oper","editoper":"edit","addoper":"add","deloper":"del","subgridid":"id","npage":null,"totalrows":"totalrows","filter":"filters","searchField":"searchField","searchOper":"searchOper","searchString":"searchString","query":"grid","excel":"excel","subgrid":"subgrid","autocomplete":"autocmpl"},"forceFit":false,"gridstate":"visible","cellEdit":false,"cellsubmit":"remote","nv":0,"loadui":"enable","toolbar":[false,""],"scroll":false,"multiboxonly":false,"deselectAfterSort":true,"scrollrows":false,"autowidth":false,"scrollOffset":18,"cellLayout":5,"subGridWidth":20,"multiselectWidth":30,"gridview":true,"rownumWidth":35,"rownumbers":false,"pagerpos":"center","recordpos":"right","footerrow":false,"userDataOnFooter":false,"hoverrows":false,"altclass":"ui-priority-secondary","viewsortcols":[false,"vertical",true],"resizeclass":"","autoencode":false,"remapColumns":[],"ajaxGridOptions":{},"direction":"ltr","toppager":"#grid_analysis_toppager","headertitles":false,"scrollTimeout":40,"data":[],"_index":{},"grouping":false,"groupingView":{"groupField":[],"groupOrder":[],"groupText":[],"groupColumnShow":[],"groupSummary":[],"showSummaryOnHide":false,"sortitems":[],"sortnames":[],"summary":[],"summaryval":[],"plusicon":"","minusicon":"","displayField":[],"groupSummaryPos":[],"formatDisplayField":[],"_locgr":false},"ignoreCase":true,"cmTemplate":{},"idPrefix":"","multiSort":false,"minColWidth":33,"scrollPopUp":false,"scrollTopOffset":0,"scrollLeftOffset":"100%","storeNavOptions":false,"regional":"en","styleUI":"jQueryUI","responsive":false,"cellurl":"./services/jqgrid/analysis_grid.php","useProp":true,"_ald":false,"id":"grid_analysis","keyName":"TAGID","localReader":{"root":"rows","page":"page","total":"total","records":"records","repeatitems":false,"cell":"cell","id":"id","userdata":"userdata","subgrid":{"root":"rows","repeatitems":true,"cell":"cell"}},"width":1195,"tblwidth":1195,"disableClick":false,"_nvtd":[453,0],"_sort":false,"navGrid":false,"filterToolbar":true,"totaltime":0,"knv":null,"_fT":{"autosearch":true,"autosearchDelay":500,"searchOnEnter":true,"beforeSearch":null,"afterSearch":null,"beforeClear":null,"afterClear":null,"searchurl":"","stringResult":true,"groupOp":"AND","defaultSearch":"bw","searchOperators":false,"resetIcon":"x","operands":{"eq":"==","ne":"!","lt":"<","le":"<=","gt":">","ge":">=","bw":"^","bn":"!^","in":"=","ni":"!=","ew":"|","en":"!@","cn":"~","nc":"!~","nu":"#","nn":"!#"},"caption":"Search...","Find":"Find","Reset":"Reset","odata":[{"oper":"eq","text":"equal"},{"oper":"ne","text":"not equal"},{"oper":"lt","text":"less"},{"oper":"le","text":"less or equal"},{"oper":"gt","text":"greater"},{"oper":"ge","text":"greater or equal"},{"oper":"bw","text":"begins with"},{"oper":"bn","text":"does not begin with"},{"oper":"in","text":"is in"},{"oper":"ni","text":"is not in"},{"oper":"ew","text":"ends with"},{"oper":"en","text":"does not end with"},{"oper":"cn","text":"contains"},{"oper":"nc","text":"does not contain"},{"oper":"nu","text":"is null"},{"oper":"nn","text":"is not null"}],"groupOps":[{"op":"AND","text":"all"},{"op":"OR","text":"any"}],"operandTitle":"Click to select search operation.","resetTitle":"Reset Search Value"}} |
Thanks Tony. I am sure having a different name on each page for the grid will be useful as you develop this framework further, so probably best to bite the bullet now and come up with a scheme that will work. Initial thoughts are to use the page name as part of the grid name as only ever have one on a page.
All good stuff though and very pleased with Version 5!
Yes – sorry saveState and loadState is correct. Test case would be:
1. Create a grid that has column/toolbar filters
2. Use toolbar filter on a column and see the results
3. Save the state of the grid
4. Move away from the page and return
5. Load state of the grid and notice the toolbar filter has been applied to the results, but you can not see the text used for the filter in the toolbar
Does that help?
Thanks for looking.
I have managed to get this working by handling it in jQuery/Javascript. So on
window.onload = function() {
I have added the code:
if (localStorage.getItem(“jqGridgrid”) != null) { // if saved grid details then use…
$.jgrid.loadState(“grid”); // change to the name of your grid</p>
}
I also add this to the window.onload function to save the state – I do it when a user leaves the page by adding
$(window).bind(‘beforeunload’,function(){
$.jgrid.saveState(“grid”); // Change to the name of the grid
});
I found that I had to check if the local storage exists before executing the loadState as it kept removing the grid – not sure why?
Note the local storage gets named jqGridgrid and I assume the grid is the name of the grid.
This actually works, but my problem is that on all my pages the the grid name is “grid” and so when you save for a grid on say analysis it tries the apply the saved data to the management grid. I realise I need to change this so each grid on a page needs it own name, but if you have any smart ideas on how I could do this without the extra work that would be great!
Hello – unfortunately I have tried that, but the pager is ignoring it and still moving to left and being overwritten by the pdf export etc. I implemented by changing as follows:
|
1 2 3 4 5 6 7 8 9 |
$grid->setGridOptions(array( "rowNum"=>30, "rowList"=>array(10,20,30,50), "sortname"=>"Name", "sortorder"=>"ASC", "hoverrows"=>true, "toppager"=>true, "pagerpos"=>center )); |
I can not use your latest version live as it messes up about 80% of my grids, so will probably wait not until this gets fixed. I am happy of the latest Trirand release as long as my license does not give up!
I am sure I took that out when trying to identify the problem, but will definitely give it a try!
Have a nice weekend.
Hello – Can you please point me in the right direction as to how I set pagerpos? I have tried to find in the docs, but cant find that parameter.
Happy to try this until you fix it.
As I said the latest Trirand release I use in live works perfectly with the exact same code I am using on your 4.8 release…
Have a nice weekend.
Just for information this is old code that has been working perfectly on the last Trirand release that we use on our live systems…
Also just to add this is old code that worked fine on the latest Trirand release we are using live at the moment.
By the way not sure what goes wrong with the post system, but on the hold php code it never formats OK – if you can look at a text view it will look fine I think. This is the same code I posted successfully on the query about the paging being on the left rather than the centre…
Hello – well it was not working with every single grid of mine, but works fine with the 4.7 tcpdf library. If you want to ship me or send a link for the new tcpdf library – very happy to try. Here is a simple example though:
|
1 2 3 4 5 6 7 8 9 10 11 12 |
<!--?php $mode = ''; $type = ''; $query = ""; // Create tag query initial select statement fro all conditions $report_name = "Admin: Origins"; // Set heading description include 'include/tag_header.php'; ?--> <div id="grid_div"><!-- start of jquerygrid --> <!--?php $_SESSION['query_type']="origin_list"; $_SESSION['grid_query']='SELECT * FROM tag_origins where company_id = '.$_SESSION['company_id']; // $_SESSION['grid_query'] = "select ID, Name, Type, Location, GPS_long, GPS_lat, status from tags where Company = ".$_SESSION['company_id'].$com_list; include ('./services/jqgrid/admin/origin_list_grid.php'); ?--></div> <!--end of jquerygrid --> <!--right panel End--> <!--Container End--> <!--wrapper End--> |
|
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 |
<!--?php ini_set('display_errors', 'on'); error_reporting(E_ALL); if (!isset($_SESSION['grid_query'])) { session_start(); } $_SESSION['user_type']==3 ? $editable=false : $editable = true; include __DIR__ . '/../../../include/jq-config.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); // Set the SQL Data source $grid->SelectCommand = $_SESSION['grid_query']; // passed by calling page // set the ouput format to json $grid->serialKey = true; $grid->setPrimaryKeyId('ID'); $grid->dataType = 'json'; // Let the grid create the model $grid->table = 'tag_origins'; // define the tabel used for deleting $grid->setColModel(); $grid->setUserDate("d-m-Y"); // set labels in the header /* Below will differ based on the type of report being executed*/ /* To be included so can set right columns settings for the query*/ $grid->exportfile = 'ZipNFC_tag_origins.xls'; $grid->setGridOptions(array( "rowNum"=>30, "rowList"=>array(10,20,30,50), "sortname"=>"Name", "sortorder"=>"ASC", "hoverrows"=>true, "toppager"=>true )); $grid->toolbarfilter = true; $grid->navigator = true; $grid->setNavOptions('navigator', array("excel"=>true,"pdf"=>true, "add"=>$editable,"edit"=>$editable,"del"=>false,"view"=>true,"cloneToTop"=>true)); $grid->setUrl("./services/jqgrid/admin/origin_list_grid.php"); $grid->setColProperty('ID', array("hidden"=>true)); $grid->setColProperty( 'company_id', array("hidden"=>true, "editoptions"=>array("defaultValue"=>$_SESSION['company_id']))); // End of bespoke JS function // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?> |
Here are two pictures – the first with the paging in the centre of the pager bottom bar and second with the paging to the left. The effect is the icons for pdf export overlap the paging buttons. When you go to click on the PDF export you get the paging instead. The reason for this is the td#pager_left html tag as a style added to it of style=”width: xxxpx”. When it is working OK there is no style added – so not sure what determines there the style width is added or not?
Picture of wrong paging position
Picture of correct paging position
Here is very simple example code of the origin grid display that is not working properly…
|
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 |
<?php $mode = ''; $type = ''; $query = ""; // Create tag query initial select statement fro all conditions $report_name = "Admin: Origins"; // Set heading description include 'include/tag_header.php'; ?> <div id="grid_div"> <!-- start of jquerygrid --> <?php $_SESSION['query_type']="origin_list"; $_SESSION['grid_query']='SELECT * FROM tag_origins where company_id = '.$_SESSION['company_id']; // $_SESSION['grid_query'] = "select ID, Name, Type, Location, GPS_long, GPS_lat, status from tags where Company = ".$_SESSION['company_id'].$com_list; include ('./services/jqgrid/admin/origin_list_grid.php'); ?> </div> <!--end of jquerygrid --> </form> </div><!--right panel End--> </div><!--Container End--> </div><!--wrapper End--> </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 |
<!--?php ini_set('display_errors', 'on'); error_reporting(E_ALL); if (!isset($_SESSION['grid_query'])) { session_start(); } $_SESSION['user_type']==3 ? $editable=false : $editable = true; include __DIR__ . '/../../../include/jq-config.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); // Set the SQL Data source $grid->SelectCommand = $_SESSION['grid_query']; // passed by calling page // set the ouput format to json $grid->serialKey = true; $grid->setPrimaryKeyId('ID'); $grid->dataType = 'json'; // Let the grid create the model $grid->table = 'tag_origins'; // define the tabel used for deleting $grid->setColModel(); $grid->setUserDate("d-m-Y"); // set labels in the header /* Below will differ based on the type of report being executed*/ /* To be included so can set right columns settings for the query*/ $grid->exportfile = 'ZipNFC_tag_origins.xls'; $grid->setGridOptions(array( "rowNum"=>30, "rowList"=>array(10,20,30,50), "sortname"=>"Name", "sortorder"=>"ASC", "hoverrows"=>true, "toppager"=>true )); $grid->toolbarfilter = true; $grid->navigator = true; $grid->setNavOptions('navigator', array("excel"=>true,"pdf"=>true, "add"=>$editable,"edit"=>$editable,"del"=>false,"view"=>true,"cloneToTop"=>true)); $grid->setUrl("./services/jqgrid/admin/origin_list_grid.php"); $grid->setColProperty('ID', array("hidden"=>true)); $grid->setColProperty( 'company_id', array("hidden"=>true, "editoptions"=>array("defaultValue"=>$_SESSION['company_id']))); // End of bespoke JS function // Enjoy $grid->renderGrid('#grid','#pager',true, null, null, true,true); $conn = null; ?> |
I actually have this happening on my grids since upgrading to 4.8! But although it is happening on some that have a hidden column it is happening on others that do not have a hidden column.
Is there an answer to this?
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top