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

Sort on empty grid causes read of datasource.

3 Answers 501 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 22 Feb 2012, 08:20 PM
Hello, I have a grid that contains the results of an ad hoc query search.  My requirements are for this sortable table to be displayed empty on the form when the user first enters the page, then populate it after they fill out the search criteria and submit, hence the autoBind:false.

            $("#userGrid").kendoGrid(
            {
                dataSource: userSearchDS,
                sortable: true,
                autoBind: false,
                height: 200,
                scrollable: true,
                columns:
                [
                    { field: "penName", title: "Pen Name" },
                    { field: "userNumber", title: "User ID", width: 150 }
                ]
            });

The problem is that if you click on one of the columns while the table is empty, it calls read on your datasource, thus populating itself.  I believe this to be a bug, but assuming it wasn't, I went about trying to create the table with sortability turned off, then turning it back on when the search is performed.  This is proving to be difficult and I'm finding myself down a rathole of javascript surgery, so a patch or an alternative solution would be appreciated.

Additionally, I have a reset button that will clear out the contents of table using this JQuery function:

$.fn.clearKendoGrid = function()
{
    var data = $(this).data("kendoGrid").dataSource._data;
    data.splice(0, data.length);
    $(this).data("kendoGrid").refresh();
}

If I click the sortable column on the empty grid, I am no longer able to clear the contents out with this function, which is weird.  I haven't had the time to investigate further, though.

3 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 23 Feb 2012, 08:24 AM
Hi,

 This is by design. Sorting the grid will call the query method of the DataSource which in turn makes the read. Currently you cannot enable sorting after the grid is initialized. As a workaround I can suggest to hide the grid until all required data is filled by the user.

Regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sean
Top achievements
Rank 1
answered on 23 Feb 2012, 04:36 PM
I was afraid that would be the response.  Fair enough. I know that doing this allows you to sort on pageable datasources, but it would be nice if the sorts were disabled when the table is empty, but I get what you're saying, the Grid is intended to be bound to data so there shouldn't be an empty table.

Has telerik considered creating a Table element that wasn't so tightly bound to data?  One of the chief difficulties I've had has been in trying to use Grids the way I've always used tables in the past, which was as much as a display element as it was for data manipulation.

In an effort to keep our web applications coherent and provide a consistent user experience, it would be nice to have a table with all of the theming/styling, sorting, filtering(?) and ease of configuration as grids.
0
Atanas Korchev
Telerik team
answered on 25 Feb 2012, 10:13 AM
Hi,

 You can create a grid from an HTML table like this.

Kind regards,
Atanas Korchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Sean
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Sean
Top achievements
Rank 1
Share this question
or