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

Grouping not working

7 Answers 708 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sanket
Top achievements
Rank 1
Sanket asked on 02 Apr 2013, 04:13 AM
hi,
 I had been trying to group the grid on the column basis (the drag and drop feature) but  I have not been able to drag and place the column in the Group Panel the column name drags with the stop sign on it.

  @(Html.Kendo().Grid(Model.PersonSearch)
    .Name("DatasGrid")
    .Columns(columns =>
    {
        columns.Bound(p => p.SlNo).Visible(false);
        columns.Bound(p => p.PersonName).Width("110px").Groupable(true);
        columns.Bound(p => p.Code).Width("70px");
        columns.Bound(p => p.Cityname).Width("300px").Groupable(true);
       .Pageable(paging => paging.PageSizes(true))
       .Sortable()
       .Scrollable()
       .Groupable()
       .Filterable()
       .Selectable(s => s.Mode(Kendo.Mvc.UI.GridSelectionMode.Multiple))
       .DataSource(dataSource => dataSource
       .Ajax()
       .Model(model => model.Id(p => p.SlNo))
       .ServerOperation(false)
       .Read(read => read.Data("AddDataBinding").Action("PersonDtls", "PersonSearch", new { area = "" }))
       )
      )

Jquery version -1.7
VS-2012

7 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 02 Apr 2013, 08:17 AM
Hi Sanket,


I would suggest you to download the latest internal build, which fixes some issues related to grouping. You should also update your jQuery version, because Kendo UI Q1 2013 requires version 1.9 . Additional information could be found on the JavaScript Dependencies page.

 

Kind regards,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sanket
Top achievements
Rank 1
answered on 02 Apr 2013, 09:26 AM
Hi Dimiter,
            Will try with the latest Jquery Version.Now is there any way to get the values selected on different page of the kendo Grid.I'm able to retain there selected state across while going from page to page but .select() retrieves values only of the current page .Any help would be appreciated.
0
Accepted
Dimiter Madjarov
Telerik team
answered on 02 Apr 2013, 01:00 PM
Hello Sanket,


By default the selection is not maintained, while paging and the select method returns only the selected values from the current page. You could use some custom object to maintain the selection and manually retrieve all selected items from it.
E.g.
<script>
    var allSelected = {};
    function change(e) {
        var grid = $("#Grid").data("kendoGrid");
        var gridView = grid.dataSource.view();
        var selection = this.select();
  
        for (var i = 0; i < gridView.length; i++) {
            var id = gridView[i].OrderID;
            if (allSelected[id] == true) {
                var isSelectedNow = false;
                for (var j = 0; j < selection.length; j++) {
                    var row = grid.dataItem(selection[j]);
                    if (row.OrderID == id) {
                        isSelectedNow = true;
                        break;
                    }
                }
                if (!isSelectedNow) {
                    allSelected[id] = false;
                }
            }
        }
  
        for (var i = 0; i < selection.length; i++) {
            allSelected[grid.dataItem(selection[i]).OrderID] = true;
        }
    }
  
    function dataBound(e) {
        var grid = $("#Grid").data("kendoGrid");
        var pageData = grid.dataSource.view();
        var newSelection = [];
        for (var i = 0; i < pageData.length; i++) {
            if (allSelected[pageData[i].OrderID]) {
                newSelection.push(grid.tbody.find(">tr[data-uid='" + pageData[i].uid + "']"));
            }
        }
        grid.select(newSelection);
    }
</script>

In this example, the allSelected object is working as hash set and identifies which items are currently selected. It contains the Ids of the items with a value of true if they are selected and false otherwise.

 

Greetings,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sanket
Top achievements
Rank 1
answered on 03 Apr 2013, 08:09 AM
Hi Dimiter,
   Thanx for reply,one another question is there any way to stop the grid from rebind after filtering the datasource using .filter.In my case i'm first loading the grid using " grid.dataSource.read();" then specifying the filter " _filter.push({ field: "Code", operator: "neq", value: columnDataVector[index] });" and then " grid.dataSource.filter(_filter);" what it does is it causes the selected item to be lost due to grid binding twice .
 
0
Dimiter Madjarov
Telerik team
answered on 03 Apr 2013, 03:10 PM
Hello Sanket,


The filter method internally calls the read method with the applied filters, so you can't prevent the second dataBound. I am not aware of the exact scenario, but if you don't need all the items, but just the filtered data, you could skip the initial read and just call the filter method with the applied filters.

 

All the best,
Dimiter Madjarov
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Sanket
Top achievements
Rank 1
answered on 09 Apr 2013, 05:54 AM
Hi Dimiter,

Tried the Filter method as you said but it works only on the first initialization of the grid i.e the read method is called only once,it allows me to filter the grid value only for the first time second time I try to filter the method defined in controller for .read of the grid is not called
0
Dimiter Madjarov
Telerik team
answered on 10 Apr 2013, 12:20 PM
Hi Sanket,


This behavior is expected when the ServerOperation(false) option is specified. In this case all operations like paging, sorting, filtering etc. are performed on the client side.

 

Regards,
Dimiter Madjarov
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
Sanket
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Sanket
Top achievements
Rank 1
Share this question
or