AshishShri
AshishShri

Reputation: 13

Kendo UI Grid Row Template Command

I'm having requirement in KendoUI Grid where I have first column as Command template for checkbox,so on its onclick event I want to get value and ids of all the columns of same selected row. below is the column section of my grid

columns: [                            
    {command: "", template: '<input type="checkbox" id="check-all" onclick="chkboxclicked(this)"/>', width: "15" },
    { field: "Hours", template: '<input type="textbox" id="txthours" style="width:70px;"/>', width: "30" },
    { field: "OT Hours", template: '<input type="textbox" id="txtOThours"  style="width:70px;"/>', width: "30" },
    { field: "SkillName", title: "Skill", width: "50" },
    { field: "UserName", title: "Technician", width: "65" },
    { field: "StartTimeString", template: '<input type="datetime" id="txtLaborstartdate" style="width:200px;"/>', title: "Start Date time", width: "75" },
    { field: "EndTimeString", template: '<input type="datetime" id="txtLaborEnddate" style="width:200px;"/>', title: "End Date time", width: "75" }
]

I have also attached a screenshot for more detail, please let me know how it can be done.

Upvotes: 1

Views: 5535

Answers (1)

Jaimin
Jaimin

Reputation: 8020

Try this,

Function chkboxclicked(obj){
       var id = $(obj).attr('id');
        var IsChecked = $(obj).is(':checked');
        var rowIndexchild = $(this).parent().index();
        var cellIndexchild = $(this).parent().parent().index();
         var grid = $("#YourGridName").data("kendoGrid");

       var datatItem = grid.dataItem(grid.tbody.find('tr:eq(' + cellIndex + ')'));


      var SkillName= datatItem.SkillName;
      var UserName= datatItem.UserName;
      var StartTimeString= $('#txtLaborstartdate').val();
      var EndTimeString= $('#txtLaborEnddate').val();
      var hours = $('#txthours').val();
      var OThours = $('#txtOThours').val();


}

You can find Hours value like $('#txthours').val().

Upvotes: 1

Related Questions