Wednesday, June 26, 2013

Kendo UI GRID Get Entire Row Value

We are using Kendo UI Grid in our Web Application.But We got problem in fetching entire row from the kendo grid.

There is a solution of two line code for this problem.

var entityGrid = $("#grdid").data("kendoGrid");
 var selectedItem = entityGrid.dataItem(entityGrid.select());



Here "#grdid" is the id of the grid specified. and selectedItem has all the values of the selected rows.

we can fetch the records value using
 
selectedItem.tblcolumnName

where tblcolumnName is the name of the column from the table.

Following is the code for grid Binding:

var Url = '<%=Request.Url.Authority + Request.ApplicationPath%>';
$("#grdid").empty();

$("#grdid").kendoGrid();

var url = "http://" + Url + "/ClientServiceProxy/NameService.svc/functionToCall";

$.getJSON(url, argument)

.done(
function (data) {

var obj = data.d;

$("#grdid").kendoGrid({

dataSource: {

data: obj,

schema: {

model: {

fields: {

Severity: { type:
"string" },

AlertMsgId: { type: "number" },

Active: { type: "string" }

}

}

},

pageSize: 5

},

serverPaging:
true,

serverFiltering: true,

serverSorting: true,

height: 200,

filterable:
true,

sortable: true,

pageable: true,

selectable: true,

dataBound: onDataBound,

columns: [

{

field:
"check_row", title: " ", filterable: false, sortable: false,

template: "<input class='inpchk' type='checkbox'/>",

title: "<input type='checkbox' id='chkSelectAll' onchange='SelectAll();'/>",

width: 34

},

{

hidden:
true,

title: "Id",

field: "Id",

width: 50

},

{

title:
"Severity",

field: "Severity",

width: 80

},

{

title:
"Message",

field: "AMsgId",

width: 80,

filterable:
true,

sortable: true

},

{

title:
"Id",

template: '<a href="\\#" target="" class="a_pop" onClick="openPopup();">#: data.Id #</a>',

width: 50

},

{

title:
"Date",

field: "strCreatedDatae",

width: 80,

filterable:
false,

sortable: false

},

{

title:
"Desciption",

field: "TypeDescription",

filterable: false,

sortable: false

},

{

title:
"Notes",

field: "Notes",

filterable: false,

sortable: false

},

{

title:
"Status",

field: "Active",

width: 70

},

{

hidden:
true,

title: "Status",

template: "<span class='spn_Active'>#: data.Active #</span>"

},

{

hidden:
true,

title: "Email",

field: "Email"

},

{

hidden:
true,

title: "Phone",

field: "Phone"

},

{

hidden:
true,

title: "Address1",

field: "Address1"

},

{

hidden:
true,

title: "Address2",

field: "Address2"

},

{

hidden:
true,

title: "FirstName",

field: "FirstName"

},

{

hidden:
true,

title: "LastName",

field: "LastName"

},

{

hidden:
true,

title: "CreatedDate",

field: "CreatedDatae"

}

]

});

});











No comments:

Post a Comment