2

I have a Kendo grid that when you click on a row, I would like it to update the contents of another grid on the page. How would you write a function to tell the grid to update the second grid? As an example, the first grid would be a list of states and the second grid would show all of the cities within the selected state.

Mike Deluca
  • 1,295
  • 2
  • 18
  • 41

1 Answers1

0

Just bind the click event on the rows of your first table :

$("#states tbody").on("click", "tr", changeState);

and then change the data of your second table accordingly :

$("#cities").data("kendoGrid").dataSource.data(getListOfCities());

Here is just some sample code : jsFiddle

animuson
  • 53,861
  • 28
  • 137
  • 147
Samuel Caillerie
  • 8,259
  • 1
  • 27
  • 33
  • thanks, i'll give that a try. it will take some tweaking to work for what i have, but it should work. – Mike Deluca Apr 22 '13 at 11:45
  • @MichaelDeluca if you want some detailed explanations don't hesitate to put a jsFiddle in a new question (or editing this one) with what you have achieved and what blocking points remains! – Samuel Caillerie Apr 22 '13 at 12:03
  • You could also use the grid's change event instead of binding a new one. – NunoCarmo Apr 22 '13 at 20:35
  • yeah the tricky part is that i'm linking from one sql query to another. so i need to filter the second table based on the unique identifier being passed from the first table. – Mike Deluca Apr 22 '13 at 23:33
  • @NunoCarmo no : the event as to be triggered at the click on a row of the first table (not when the content of this table changes...). But it can be bound to the select event if the selection has been enabled... – Samuel Caillerie Apr 23 '13 at 06:56
  • @Samuel Caillerie According to docs change event Fired when the user selects a table row or cell in the grid http://docs.kendoui.com/api/web/grid#events-change – NunoCarmo Apr 23 '13 at 13:41
  • @NunoCarmo yes, but if you look at the example, this works only if we have activated cell or row selection on the table... – Samuel Caillerie Apr 23 '13 at 13:45