2

I have a dropdown(having 2 values - Employee and department) and two kendogrids(emp grid and dept grid), on change of dropdown I am enabling/disabling grid based on dropdown value and also clearing datasource of both grid, when I select employee in dropdown and sort employees based on name it gives results, when i change dropdown value to 'Department' it disables employee grid and shows 'No data found' in employee grid,but when I clicked on EmpName column i still got the previous results. I have added dropdown change sample code below.

    var ddlvalue = $("#drpmodule").data("kendoDropDownList").text();

       $("#EmpGrid").data("kendoGrid").dataSource.data([]); //Clear EmpGrid DataSource
       $("#DeptGrid").data("kendoGrid").dataSource.data([]); //Clear DeptGrid DataSource

          if (module == 'Employee') {
                $('#DeptGrid').addClass('k-state-disabled');
                $('#EmpGrid').removeClass('k-state-disabled');                            
          }
          else if (module == 'Department') {

               $('#EmpGrid').addClass('k-state-disabled');  //shows no data found in EmpGrid, but clicking on column header gives results                        
               $('#DeptGrid').removeClass('k-state-disabled');

          } else {
                    $('#EmpGrid').removeClass('k-state-disabled');
                    $('#DeptGrid').removeClass('k-state-disabled');
                }

I am not getting why Employee grid is showing previous/old data even after 'No data found' records(on changing dropdown).

Silicomancer
  • 8,604
  • 10
  • 63
  • 130
Learner1
  • 99
  • 1
  • 11

1 Answers1

1

It would be nice to see how the datasource is configured.

As it is I can assume that maybe when you are filtering, the datasource is fetching data. It would explain why you see data on filtering the empty grid.

Maybe hiding the disabled grid could be a solution : $('#EmpGrid').hide();
Then display it again $('#EmpGrid').show();
By hiding/showing the grid you don't need to empty the grid anymore.

Azepic
  • 66
  • 1
  • 2
  • 5
  • have just gone through https://stackoverflow.com/questions/17917962/how-to-remove-all-rows-from-a-kendo-grid and get to know that $("#EmpGrid").data("kendoGrid").dataSource.data([]); has a problem with it, it will show old data in case of sorting/filteringm, so i created a new empty datasource and assigned it to grid on dropdown change, again i assigned old datasource to grid on click of search button. Thanks for Help btw :-) – Learner1 Aug 26 '19 at 09:33