2
votes

I writting a html/javascript page with a kendo grid with filter menu. I have faced the following problem: when I add a new object to the data source (new row) and its kendogrid is reloaded (datasource.read) I lose the textboxes values inside the filter menu that I was inputting the values.

Here is the demo: http://jsfiddle.net/3qT3J/2/

$("#grid").kendoGrid({
    dataSource: datasource1,
    height: 300,
    filterable: true  // <== shows a button on each column that display a filter menu

});
// reload the grid every 2 seconds:
 setInterval(function() {
        datasource1.read();
 }, 2000); 

Is there any way to fill the textboxes again when the grid is reloaded? how can I get the values entered by the user? Is there some kendogrid property that avoid to lose the values when the grid is reloaded?

I thought to get the values with an event listener in the textboxes, but I don't know which column the text box belongs... I added the event listener with the following code: $(".k-textbox").on("click change", function1);

Any idea? Thanks

1
try creating a demo (jsfiddle/jsbin/plnkr); dataSource.read() won't delete your filters - Lars Höppner
yes, the dataSource.read() don't delete my filters, but deletes what the user is writing in the graphic interface. When the user open the filter menu and start to input some value, this value is cleared when call datasource.read(). I call dataSource.read() every 1 second. I will write an demo and post in a fews minutes, thank you. - paulalopesfc
Lars, I added a link of a demo in the message above. Thank you. - paulalopesfc
does anyone have any suggestion? - paulalopesfc

1 Answers

1
votes

You could pause reloading while the filter menu is open so the user can finish typing:

setInterval(function () {
    var pauseRefresh = $(".k-filter-menu:visible").length;
    if (!pauseRefresh) {
        datasource1.read();
    }
}, 2000);

(demo)