Reload/refresh grid data

Hi all,

I’m using a grid to list a set of registers of my database.
Also when click a button my web show a window with a form to add new registers.

I have problems when I proceed to close the window and reload data in the grid.

Basically, I’m using these sentences:

grid_1.clearAndLoad(“sql.php”);
window_new.close();

My problems are 2 :

  1. The first time I init the grid, I’m able to navigate using keyboard, but after the “clear and load” instruction, the grid doesn’t allow to navigate using keyboard.

I have tried adding this sentence:

grid_1.enableKeyboardSupport(true);

But it doesn’t work.

  1. How can I mantain filters after the operation of “clear and load” ?

Thanks for your cooperation !

Albert

  1. Unfortunately the issue with the keyboard problem cannot be reproduced locally.
    Could you please, share with a demo link or a complete demo, where the problem can be reconstructed.

  2. You may try to use the following solution to restore the filters after the data reloading.

val=myGrid.getFilterElement(ind).value; // save value of the required filter input myGrid.clearAndLoad(url,function(){//reload data //aftercall myGrid.getFilterElement(ind).value=val //set the saved value to a filter input back myGrid.filterByAll(); //force the filter procedure });

I use this 2 sentences:

var filterObject= grid_1.getFilterElement(0).value;

And it works ok, but when I execute:

grid_1.setFilterElement(0).value = filterObject;

I get this error message:

grid_1.setFilterElement is not a function.

thanks

muncu

it was an error in the code … you should use myGrid.getFilterElemet(inde) before and after clear and load

val=myGrid.getFilterElement(ind).value; // save value of the requitred filter input
myGrid.clearAndLoad(url,function(){//reload data
//aftercall
myGrid.getFilterElement(ind).value=val //set the saved value to a filter input back
myGrid.filterByAll(); //force the filter procedure
});

I apologize. paul.sas is right.
It was a mistake in my suggested code.
there is no setFilterElement() function. You should use the getFilterElement() function.

Hi all,

regarding mi first issue:

I attached a URL, where you can see my 2 problems:

  1. Once I click on “New customer” button, and I add “surname”, “name”, “email” and click on Save button, then grid doesn’t display the new value until y refresh the page manually.

  2. Also when “New customer” pop up is closed , I cannot navigate through grid using the arrows of my keyboard.

URL : http://muncu.net/02CORE/customers.php

Please advice !

Thanks in advance

muncu

  1. Once I click on “New customer” button, and I add “surname”, “name”, “email” and click on Save button, then grid doesn’t display the new value until y refresh the page manually.
    This is the expected behavior as you are adding the record directly to the datastore but not to a dhtmlxGrid.
    So you need to refresh the grid data. But it should be performed after the data is completely updated in the datastore. This moment can be controlled with the onStoreUpdated event:
    docs.dhtmlx.com/api__datastore_o … event.html

  2. Also when “New customer” pop up is closed , I cannot navigate through grid using the arrows of my keyboard.
    Please, try to call the myGrid.setActive(true) method after the pop-up is closed:
    docs.dhtmlx.com/api__dhtmlxgrid_setactive.html

Thank you Sematik !

Point 1 is solved.

Point 2 doesn’t work.
It’s strange because months ago I did a similar web but using different Skin (skyblue) and It works with the same code that I’m using now.

Could the skin affects to this behaviour ?

Albert

It cannot be affected by a skin.
Pleas,e provide with the updated link, so that the problem can be checked.

Hi Sematik,

after some hours, I have detected the error.

I use sentence:
form_new.bind(grid_1);

which I think is not necessary.

And If i delete it , then grid works ok.

Thanks for your cooperation.

Muncu