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

How to select the first row of a grid, based on the value of a certain cell ?

2 Answers 1066 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thierry
Top achievements
Rank 1
Thierry asked on 14 Mar 2012, 12:09 PM
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 = $("#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"
                  }
              ]
          });

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 15 Mar 2012, 10:21 AM
Hello Thierry,

Here is an example of how you can select row depending on data which given row displays:
http://jsfiddle.net/5N5pN/

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Thierry
Top achievements
Rank 1
answered on 15 Mar 2012, 10:24 AM
thank you, it works well !
Tags
Grid
Asked by
Thierry
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Thierry
Top achievements
Rank 1
Share this question
or