Home › Forums › Guriddo Suito PHP › another refresh grid issue
I have seen many people struggling with the issue of refresh grid not working. I see some examples in the demos but none that actually answer the question that many seem to have with JSON data. If you load the data with JSON and use the loadonce:true there seems to be no clear answer as to how to get the grid to refresh after the data has been edited. I have a reloadGrid function that I use in the page but I am unable to get it to fire when edits are done. Is there a demo that shows how to load from SQL and then edit locally and cause it to reload with the JSON again after an edit?
I tried using afterSubmit and reloadAfterSubmit in my Navgrid to call my reloadGrid function but it does not get called. I tried putting alert messages into those as well and they dont get called either.
The data is getting update on the server so I know the edit is being run.
Hello,
I think I should explain what is happen.
When you do loadonce true the datatype becomes local and the grid sorting paging and etc are performed with the local data array, but the editing is done on the server. This mean that all CRUD operations are done server side via ajax.
By default reloadAfterSubmit is true which means if the posting of the newdata is server side the grid expects, that reloading is done server side, but it is not since loadonce dynamically chnaged this.
In order to resolve your problem you must set reloadAfterSubmit to false. This causes the new data to be manipulated with the local grid functions and in the samne time the data to be posted on the server.
Simple do this:
|
1 2 3 |
$grid->setNavOptions('edit', array("reloadAfterSubmit"=>false)); $grid->setNavOptions('add', array("reloadAfterSubmit"=>false)); |
which will resolve the problem. In this case there is no need to put additionally reloadGrid in any code.
Kind Regards,
Will
Guriddo Support Team
reloadAfterSubmit:false, is set to false and it did not work. In this case I was trying to reload the grid because I could not figure out a way to actually run a delete row function call after the grid was updated.
I have a grid that loads as a result of a large query. the result is a set of data that the user will then edit and as a result of that edit it should be removed from the grid. So for example of there were 10 rows I want the user to see 9 after the edit. Since the query is long running it would be better if i just removed the row but since I cant get any function calls to run after the edit i was being forced to reload the grid but that does not work either. I tried putting alerts in various spots and none of them fire so it seemed they dont get called.
Hello,
For delete you should add the same command.
|
1 2 3 |
$grid->setNavOptions('del', array("reloadAfterSubmit"=>false)); ... |
In order to test this add these 3 lines of code of any editable form example and you will see that it will work.
Kind Regards,
Will
Guriddo Support Team
Hello,
Do you have clear the browser cache after change the code?
Do you use our PHP component or JavaScript only? Where and how you put this code?
Can you please share your code?
Thank you
Guriddo Support Team
I think am confusing it a bit. I am working on 2 things at once with no luck. I thought that the arrays were in order so that closeAfterEdit: true, editCaption:”Update Row”, bSubmit:”Update” were all being done then the add options, then the edit options, then the delete option arrays all kicked in?? the page reloads on the delete but not after the edit. and the excel part never shows on the screen at all.
jQuery(“#acct_list”).jqGrid(‘navGrid’,’#pager’,
{
add:false, edit:true, del:true, excel:true, edittext: ‘Edit’
},
{
closeAfterEdit: true, editCaption:”Update Row”, bSubmit:”Update”
},
//{}, // add options
{closeOnEscape:true,jqModal:true,bottominfo:”Fields marked with (*) are required”,
reloadAfterSubmit:false,
closeAfterEdit:true,
//afterSubmit:actionAfterSubmit
},// edit options
{reloadAfterSubmit:false} // del options
);
Hello,
This is exactly your example
As can be seen reloading is working fine. When you do reload from navigaror we reload the data currently loaded in the local data array.
If you want to reload the fresh data from server you will need to se before this the datatype to json and then do reload. Note that in this case since loadonce is true after loading data from server the datatype again goes to local.
Regards
Will
P.S. Our edit url does not do any save to server it is only for demo.
Guriddo Support Team
so i looked at the example and i figured out why mine was failing. i had an empty array for the add function that was false, that was making the attributes point to the wrong pieces of code.. so i resolved that now.
My issue is still that i want to delete the row after the edit. how do i call a something to remove the row from the grid without reloading from the server? or for example after the edit is done i wanted an alert message to tell them the record was updated? where would that code go?
also in this example i see excel:true but it is not showing the icon for the excel download? i have that same issue. does the icon not show up when the data is local?
Hello,
In the example provided you can edit and after edit is done you can delete the row.
I have say two possible reloads.
1. If you just do reloadGrid without to change the datatype to json the reload is local
2. If you set datatype to json and then reload the reload is done server side.
I do not understand what you mean.
About the alert message – you may want to see the documentation here
See events – maybe afterSubmit event is a good choice.
You have posted your question in the wrong forum – you post it in PHP, but it should it in JavaScript.
The excel true is available only in PHP edition.
To have export to excel you should create your own navButton add method for this purpose.
Kind Regards,
Will
Guriddo Support Team
I guess this explains my confusion.. I dont know what you mean when you say post it in the JS vs PHP forum? my page is all php? I will rephrase the issue
but nothing happens when the data is returned. I dont see a demo of using these options only the excel:true option and when that is used nothing happens at all that i can see.
Hello,
Should we think that the other problems you have are resolved.
Note that the export is done server side.
We have a lot of examples for export.
Go here
and select Export tab from the Accordion.
Check if you have set correct paths to the modules.
Kind Regards,
Will
Guriddo Support Team
I dont see any examples that i can get to work. if i use excel:true no export icon shows up. Many others have reported the same issue and I dont see what the answer is to that problem.So i have no way to export the data. I have all the excel options set to what you have.
I tried using something like this with my own customer button
jQuery(“#acct_list”).jqGrid(‘navButtonAdd’,’#pager’,{
caption:”Export To Excel”,
onClickButton : function () {
var e = document.getElementById(“load_template”);
var the_template = e.options[e.selectedIndex].value;
jQuery(“#acct_list”).jqGrid(‘excelExport’,{“url”:”getEBKFSdata.php?&the_template=”+the_template});
});
}
});
this shows up and i can click it and call the php but nothing comes back the download and i am not clear how to format it in the php page that gets the data. i dont see any examples of something like this.
Hello,
Please tell us which version of jqGrid php is used and which version of jqGrid JavaScript is used?
Please post your code (or send it to us) including all scripts – javascript and php and html
We can not help other way.
I suggest you to start with the demo in order to see if it is working (the export)
Kind Regards,
Will
Guriddo Support Team
Copyright 2014 TriRand LtdAll Rights ReservedRSS
Back to Top