This is a migrated thread and some comments may be shown as answers.

When adding a new datasource the search field no longer work

6 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ole
Top achievements
Rank 1
ole asked on 24 Sep 2020, 12:24 PM

This might not be the way to go but after a buttonclick i want to update the content of a grid. I do this by making an ajax request and setting a new datasource to the grid with the response. Only problem is after i have done that the search field no longer work

See dojo for example

 

https://dojo.telerik.com/uvAZuvEW/3

6 Answers, 1 is accepted

Sort by
0
ole
Top achievements
Rank 1
answered on 24 Sep 2020, 12:25 PM
0
ole
Top achievements
Rank 1
answered on 24 Sep 2020, 12:44 PM

nvm, i got it to work by using this 

setDataSource instead

$('#grid').data("kendoGrid").setDataSource(new kendo.data.DataSource({ data }))

https://dojo.telerik.com/uvAZuvEW/4

 

0
Nikolay
Telerik team
answered on 28 Sep 2020, 06:51 AM

Hello Ole,

Thank you for updating us on the case.

Indeed, using the setDataSource() is the remmended way to go with when the requirment is to set a new data source and re-render the Grid with the new data.

Please let me know if you have any further questions.

Regards,
Nikolay
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

0
ole
Top achievements
Rank 1
answered on 29 Sep 2020, 11:10 AM

Thanks, actually;

if you search for something in the grid, and then replace the datasource is there a way to automaticaly apply the search "filter" to the new datasource ?

0
ole
Top achievements
Rank 1
answered on 29 Sep 2020, 11:28 AM

haha so sorry, again here to answer my own Q:

 

  const filter = $('#grid').data("kendoGrid").dataSource.filter()
  $('#grid').data("kendoGrid").dataSource = new kendo.data.DataSource({ data });
  $('#grid').data("kendoGrid").dataSource.filter(filter);
  $('#grid').data("kendoGrid").dataSource.read();
  $('#grid').data("kendoGrid").refresh();

https://dojo.telerik.com/uvAZuvEW/5

0
Nikolay
Telerik team
answered on 01 Oct 2020, 10:26 AM

Hello Ole,

Indeed, that is how a filter can be applied to the grid data source.

Please let us know if anything new arises.

Regards,
Nikolay
Progress Telerik

Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).

Tags
Grid
Asked by
ole
Top achievements
Rank 1
Answers by
ole
Top achievements
Rank 1
Nikolay
Telerik team
Share this question
or