Hi ,
i worked on kendo grid i have solved an problem per Persist selected rows while paging.
Following is the code
$(document).ready(function($) {
var selectedIds = {};
var grid = $("#grid");
grid.kendoGrid({
dataSource: {
data: myData(),
schema: {
model: {
id: 'Id',
fields: {
select: {
type: "string",
editable: false
},
Id: {
type: "number"
},
FirstName: {
editable: true
},
LastName: {
type: "string"
},
City: {
type: "string"
},
Title: {
type: "string"
},
BirthDate: {
type: "date"
},
Age: {
type: "number"
},
}
}
},
pageSize: 5
},
editable: false,
selectable: "multiple",
sortable: {
mode: 'single',
allowUnsort: false
},
pageable: true,
columns: [
{
field: 'LastName',
title: 'Last Name',
width: 120},
{
field: 'City'},
{
field: 'Title',
width: 230},
{
field: 'BirthDate',
title: 'Date Of Birth',
width: 120,
format: "{0:MM/dd/yyyy}",
template: '#= kendo.toString(BirthDate, "MM/dd/yyyy")#'},
{
field: 'Age',
width: 80}],
dataBound: function() {
var grid = this;
var selected = $();
var ids = selectedIds[grid.dataSource.page()] || [];
for (var idx = 0, length = ids.length; idx < length; idx++) {
selected = selected.add(grid.table.find("tr[data-uid=" + ids[idx] + "]"));
grid.select(selected);
}
},
change: function () {
var grid = this;
var ids = selectedIds[grid.dataSource.page()] = [];
grid.select().each(function () {
dataItem = grid.dataItem($(this));
ids.push($(this).data().uid);
});
}
});
});
Thanks
Amol Gunjal
i worked on kendo grid i have solved an problem per Persist selected rows while paging.
Following is the code
$(document).ready(function($) {
var selectedIds = {};
var grid = $("#grid");
grid.kendoGrid({
dataSource: {
data: myData(),
schema: {
model: {
id: 'Id',
fields: {
select: {
type: "string",
editable: false
},
Id: {
type: "number"
},
FirstName: {
editable: true
},
LastName: {
type: "string"
},
City: {
type: "string"
},
Title: {
type: "string"
},
BirthDate: {
type: "date"
},
Age: {
type: "number"
},
}
}
},
pageSize: 5
},
editable: false,
selectable: "multiple",
sortable: {
mode: 'single',
allowUnsort: false
},
pageable: true,
columns: [
{
field: 'LastName',
title: 'Last Name',
width: 120},
{
field: 'City'},
{
field: 'Title',
width: 230},
{
field: 'BirthDate',
title: 'Date Of Birth',
width: 120,
format: "{0:MM/dd/yyyy}",
template: '#= kendo.toString(BirthDate, "MM/dd/yyyy")#'},
{
field: 'Age',
width: 80}],
dataBound: function() {
var grid = this;
var selected = $();
var ids = selectedIds[grid.dataSource.page()] || [];
for (var idx = 0, length = ids.length; idx < length; idx++) {
selected = selected.add(grid.table.find("tr[data-uid=" + ids[idx] + "]"));
grid.select(selected);
}
},
change: function () {
var grid = this;
var ids = selectedIds[grid.dataSource.page()] = [];
grid.select().each(function () {
dataItem = grid.dataItem($(this));
ids.push($(this).data().uid);
});
}
});
});
Thanks
Amol Gunjal