grid selection - model/row

6 posts, 0 answers
  1. Piyush Bhatt
    Piyush Bhatt avatar
    166 posts
    Member since:
    Nov 2007

    Posted 24 Dec 2011 Link to this post

    This is mix of datasource/grid question. 

    I have a [search] box with some criteria where user can enter some values and search, results gets displayed in grid and then I want to select the row. I am trying to get the [object] relevant to that row.

    In following code, everything works upto selecting a row. I am not using the 'datasource' specification but instead using it within the search-click method. but how should I specify the schema/mode/id here so that when I select the row I can get row.data("id") value? As per following code, row.data("id") value is null.

    Also, .data() method allows to store any object at the element level then why dont you store the whole object for the whole row.data()? and why you store only id? 

                    $("#btnSearch").click(function() {
                        var searchobj = $("#searchForm").toDeepJson();
                        //console.log(searchobj);
                        myajax.WebService.SearchCustomers(searchobj, function(result) {
                            console.log(result.d);
                            gridCustomers.dataSource = new kendo.data.DataSource({
                                data: result.d,
                                schema: {
                                        model: { id: "Name" }
                                }
                            });
                            gridCustomers.dataSource.read();
                            gridCustomers.refresh();
                        }); //searchcustomers
                    }); //btnSearch.click
                });                              //doc-ready


                function onChange(arg) {
                    var row = this.select();
                    var id = row.data("id");
                    console.log(id);
                }
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 27 Dec 2011 Link to this post

    Hello Piyush,

    Generally speaking I do not see why you need to recreate Grid DataSource every time you change the filter criteria. The following jsFiddle demonstrates how you can achieve similar behavior by using DataSource filtering capabilities.

    http://jsfiddle.net/rusev/ZpCAy/3/

    To have id generated for the item you need to define schema/model/id. Then you can retrieve the Model for the item from the DataSource and access all it's properties via get method.

    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!
  3. Kendo UI is VS 2017 Ready
  4. BSV
    BSV avatar
    3 posts
    Member since:
    Mar 2009

    Posted 29 Dec 2011 Link to this post

    Hello

    I have a similair problem as Piyush, and I've taken a look at the example. However, I don't wat to use the filter of the datasource, but rather want to use a json call to a server to do the filter for me.

    Filtering on the datasource is not possible since the filtering is not straight forward (that is just a string matching) and requires a SQL server.

    How can I reload the datasource ?

    Kind regards Martijn
  5. RMC
    RMC avatar
    11 posts
    Member since:
    Jan 2012

    Posted 24 Jan 2012 Link to this post

    $("#grid").data("kendoGrid").dataSource.filter({});
  6. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 25 Jan 2012 Link to this post

    Hello Martijn,

    To refresh the data in DataSource you must filter it. 

    "Filtering on the datasource is not possible since the filtering is not straight forward (that is just a string matching) and requires a SQL server."

    I don't understand what do you mean. Can you explain?

    Filtering in the case of the example in my previous post is performed on SQL server which is used by the service.

    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!
  7. RMC
    RMC avatar
    11 posts
    Member since:
    Jan 2012

    Posted 25 Jan 2012 Link to this post

    I posted  $("#grid").data("kendoGrid").dataSource.filter({});  because I use JSON data instead of  'odada', I had to implement the filter logic in the server side, calling ...filter({}) without filter conditions refresh the Data Source and get back all records
Back to Top
Kendo UI is VS 2017 Ready