Hello,
i'm searching for the good method to select a row in my grid, based on an identifier (a product's reference).
My datasource is an xml file. In the sample, I used the books.xml from Kendo and the searching should be based on the 'reference' column.
All samples I've found used a filter, but I just need to select the first row which match, not filtering all data.
Is there a good method to do that ?
Thanks in advance
function selectByref (theReference)
{
var row =
}
var theGrid = $("#grid").kendoGrid({
dataSource: {
//data: movies,
transport: {
read: {
url: "http://demos.kendoui.com/content/web/datasource/books.xml",
dataType: "xml"
}
},
schema: {
// specify the the schema is XML
type: "xml",
// the XML element which represents a single data record
data: "/books/book",
// define the model - the object which will represent a single data record
model: {
// configure the fields of the object
fields: {
// the "title" field is mapped to the text of the "title" XML element
reference: "title/text()",
// the "author" field is mapped to the text of the "author" XML element
author: "author/text()",
// the "url" field is mapped to the text of the "url" XML element
link: "url/text()",
// the "cover" field is mapped to the "id" attribute of the "book" XML element
image: "@cover"
}
}
}
},
//change: onChange,
sortable: true,
filterable: false,
selectable: "multiple row",
scrollable: true,
columns: [
{
field: "reference",
title: "Référence"
},
{
field: "author",
title: "Auteur"
},
{
field: "link",
title: "Lien"
},
{
field: "image",
title: "Image"
}
]
});
i'm searching for the good method to select a row in my grid, based on an identifier (a product's reference).
My datasource is an xml file. In the sample, I used the books.xml from Kendo and the searching should be based on the 'reference' column.
All samples I've found used a filter, but I just need to select the first row which match, not filtering all data.
Is there a good method to do that ?
Thanks in advance
function selectByref (theReference)
{
var row =
$("#grid
"
).data("
kendoGrid"
).table.find(
'tr[reference="'
+ theReference+
'"]'
);
$("#grid").select (row);}
var theGrid = $("#grid").kendoGrid({
dataSource: {
//data: movies,
transport: {
read: {
url: "http://demos.kendoui.com/content/web/datasource/books.xml",
dataType: "xml"
}
},
schema: {
// specify the the schema is XML
type: "xml",
// the XML element which represents a single data record
data: "/books/book",
// define the model - the object which will represent a single data record
model: {
// configure the fields of the object
fields: {
// the "title" field is mapped to the text of the "title" XML element
reference: "title/text()",
// the "author" field is mapped to the text of the "author" XML element
author: "author/text()",
// the "url" field is mapped to the text of the "url" XML element
link: "url/text()",
// the "cover" field is mapped to the "id" attribute of the "book" XML element
image: "@cover"
}
}
}
},
//change: onChange,
sortable: true,
filterable: false,
selectable: "multiple row",
scrollable: true,
columns: [
{
field: "reference",
title: "Référence"
},
{
field: "author",
title: "Auteur"
},
{
field: "link",
title: "Lien"
},
{
field: "image",
title: "Image"
}
]
});