2

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

  • try creating a demo (jsfiddle/jsbin/plnkr); dataSource.read() won't delete your filters – Lars Höppner Jan 15 '14 at 11:28
  • 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 Jan 15 '14 at 11:53
  • Lars, I added a link of a demo in the message above. Thank you. – paulalopesfc Jan 15 '14 at 13:13
  • does anyone have any suggestion? – paulalopesfc Jan 16 '14 at 12:01

1 Answers1

1

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)

Lars Höppner
  • 18,252
  • 2
  • 45
  • 73
  • As a workaround I've stopped and started datagrid reload on the mouseenter and mouseleave event listener of the filter menu. Ex: "$('form.k-filter-menu').mouseenter (function...)". But your solution is better. Thank you very much. – paulalopesfc Jan 16 '14 at 14:41
  • you're welcome; since you're a new member: if an answer was helfpul, you should consider upvoting it (using the arrows on the left of the post), and if your problem is solved, you should [accept an answer](http://meta.stackexchange.com/a/5235) – Lars Höppner Jan 16 '14 at 15:12