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

Kendo Grid Retrieving Model Values

3 Answers 456 Views
Grid
This is a migrated thread and some comments may be shown as answers.
dipak
Top achievements
Rank 1
dipak asked on 01 Jan 2019, 03:14 PM
I have used Kendo grid and have a checkbox placed on top of grid, now grid is suppose to change data on basis of checkbox click, without making grid refresh.

Additionally tried bellow code in onCheck(e) function, but not getting updated model values -

var grid = $("#grid").data("kendoGrid");
var gridData = grid.dataSource.view();


///////////////////////////// Code CheckBox Implementation /////////////////////////////////////////////////////////////////////////
 @(Html.Kendo().CheckBox()
      .Name("Check")
      .HtmlAttributes(new { onchange = "onCheck();" })
      .Label("Check")

    function onCheck(e) {
      var grid = $("#grid").data("kendoGrid");
       var gridData = grid.dataSource.view();
     // gridData - not getting updated model data.
     // Here e is coming as "undefined"
    // I need something => e.model  //e.model.USER_ID
    }
Hence, here in onCheck(e) function, i need to pass "e" , so that i can do something like "e.model" so that i can get my values for e.g. "e.model.USER_ID"
Thanks

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 02 Jan 2019, 10:41 AM
Hi Dipak,

In order to use a header template in the Grid I would suggest the approach illustrated in the following example:


Give it a try and let me know how it works for you.


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
dipak
Top achievements
Rank 1
answered on 02 Jan 2019, 08:53 PM

Thanks Viktor, for your reply. My requirement is I have got data which is flag column like true or false for each row. Now when the grid is loaded  for the first time, it comes with all the record i.e. record with status true and false as well .Now if the user selects or checks the checkbox, then grid with populate data who has status as false.

Now to implement this, i have used a checkbox and in  its "onCheck" event, i am going to set record to the grid whose status is false.

Here my question is - How can i get grid properties like event and sender of grid via "e" parameter, so that i can implement something like - "e.model.USER_ID".

 @(Html.Kendo().CheckBox()
      .Name("Check")
      .HtmlAttributes(new { onchange = "onCheck();" })
      .Label("Check")

    function onCheck(e) {
      var grid = $("#grid").data("kendoGrid");
       var gridData = grid.dataSource.view();

     // Here e is coming as "undefined"
    // I need something => e.model  //e.model.USER_ID
    }

Thanks.

0
Viktor Tachev
Telerik team
answered on 04 Jan 2019, 11:22 AM
Hello Dipak,

Based on the description it seems that you would like to use filtering in the Grid. The widget has such functionality available out of the box. In order to enable it you should include the filterable option. Furthermore, there is a MultiCheckbox filter mode that enables the users to select the options they want via checkboxes. Check out the example below that illustrates the functionality. 



Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
dipak
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
dipak
Top achievements
Rank 1
Share this question
or