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

Sort problem: Enable/Disable Single Column Sort on a per column basis

6 Answers 792 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Cary Abramoff
Top achievements
Rank 1
Cary Abramoff asked on 13 Nov 2011, 03:28 AM
Hi,

I have a select column and I want to put a checkbox in the header.
Further only 2 of my columns should allow sorting.
In fact I remove via JQuery the rest of the column captions because they skew my layout. For example, I use icons that are very narrow but the column name is 10x longer than the icon.

So to make a long story short I have columns sorting (all but 2) that should never be sortable.
I tried unbinding the click handler on the  $('.k-link').each(function () {.... massage col headers}) but they still sort and I do not see the inline event handlers so I fear it is in the framework and I have no control over sorting.

Even worse, due to this behavior my checkbox cannot hold the state because the grid column header events supersede the checkbox behavior I need so my users can select/deselect an entire page of data.

I have included a snapshot.
I want the checkbox for col1 header to select/deselect all rows on the page. I tried your select code but I feel this common pattern works better for me.

Finally I only want the two columns with text headers to be sortable. I tried adding sortable to the col definition of the grid but it ignores the attribute.

Any suggestions would be welcome!

Cary






6 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 14 Nov 2011, 03:02 PM
Hi Cary Abramoff,

 Unsortable columns are not currently implemented. I have logged this for implementation. Should be ready for the official release. The code would be something like this:

columns: [
   {
      field: "field",
      sortable: false
   }
]

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
Cary Abramoff
Top achievements
Rank 1
answered on 15 Nov 2011, 12:00 AM
Thanks for the speedy reply Atanas and THANKS FOR IMPLEMENTING MY SUGGESTION! THANKS THANKS THANKS!!


I hope Kendo UI sweeps the web.

Telerik is always shining a light in the darkness that is cross browser development.

:))

Cary
0
Joe
Top achievements
Rank 1
answered on 23 Dec 2011, 11:57 PM
Hi,

We have a similar problem but with grouping. We have a checkbox column in the grid and we have grouping activated. The grouping works perfectly with all columns except with the checkbox, when the user drags the checkbox column to the grouping a javascript error is returned.
Since, in our case it doesn't make much sense to group by the checkbox column we would like to be able to add something like:

columns: [
   {
      field: "field",
      groupable: false
   }
]

but this doesn't seem to work.
In the mean time we have deactivated the event with:

$('#field a').bind('mousedown',false);
$('#field').bind('mousedown',false);

Hope this feature gets implemented in the future.

Joe
TSolucio
0
Nikolay Rusev
Telerik team
answered on 27 Dec 2011, 04:32 PM
Hello Joe,

We will add support for groupable setting of Grid columns, but could you please help us replicate the error by grouping on boolean value. For your convenience I am posting jsFilddle that seems to be working properly with grouping on booleans.

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

Greetings,
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
Joe
Top achievements
Rank 1
answered on 31 Dec 2011, 08:29 PM
Hi Nikolay,

It took me a while to get a base example with the error because my first assumption was incorrect. It isn't a problem with the grid grouping on boolean or checkbox, which works correctly, but having spurious characters in the table. I attach an example that produces the error, but I'm not sure this is a KendoUI problem or formatting error.

<table id="chkbox">
<tr>
<th data-field="selectid"><input name="il_all" type="checkbox">Select</th>
<th data-field="name">Name</th>
</tr>
<tr><td>
<input name="il1" id="il1" type="checkbox"></td><td>John</td></tr>
<tr><td><input name="il2" id="il2" type="checkbox"></td><td>Mary</td></tr>
<tr><td><input name="il3" id="il3" type="checkbox"></td><td>John</td></tr>
</table>
<script type="text/javascript">
$("#chkbox").kendoGrid({
    columns: ["selectid", "name"],
    height: 400,
    groupable:true
});
</script>

Notice the extra "return" or new line on the first <td>, this produces a javascript unterminated string error which breaks the grouping. The exact same problem appears if you add the new line before "John", it has nothing to do with boolean or checkbox.

Thank you for you follow through.
I wish you, all the team and all community members a very Happy New Year.

Joe
TSolucio
0
Nikolay Rusev
Telerik team
answered on 03 Jan 2012, 11:05 AM
Hello,

Yes, this is correct, the "↵" /carriage return/ breaks the formatting. Otherwise the Grid seems to function properly.

All the best,
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!
Tags
Grid
Asked by
Cary Abramoff
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Cary Abramoff
Top achievements
Rank 1
Joe
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or