Search code examples
kendo-uikendo-gridkendo-datasource

best practice when need to change grid options/datasource


In an application I'm developing, i need to use the same space to display information from different sources with different formats in a grid according to what item was selected on a TreeView.

i found two ways to achieve this:

  1. find the grid then destroy and recreate it.
  2. find the grid then change datasoruce/options/

I'm very new to Kendo, so i'm not sure which approach would be wiser.

any advice?


Solution

  • The answer depends on your usage model.

    1. How often are you going to change between datasources?
    2. How long does it take getting the new data?
    3. How much data is involved?

    If it takes long time and you can switch quite often between DataSources I would go with a third approach that is having several grids and only one visible BUT if there is a lot of data involved then you should destroy the grid and recreate a new one avoiding having a lot of memory used but having to bring a lot of data back and forth.

    You can go with the your second proposal (switching datasources) if you switch data and the structure of the grid is exactly the same (same columns and formatting).