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

Grid sorting for just one column

3 Answers 4646 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joe
Top achievements
Rank 1
Joe asked on 10 Feb 2012, 06:12 PM
I just want one column in my grid to be sortable. I was thinking I could make the grid set to "sortable: false" and put "sortable: true" on my one column, but no dice.

3 Answers, 1 is accepted

Sort by
0
Joe
Top achievements
Rank 1
answered on 13 Feb 2012, 10:30 PM
Are these forums dead or am I asking for something ground-breaking here.
1
Shannon
Top achievements
Rank 1
answered on 14 Feb 2012, 12:16 AM
Experimenting in jsFiddle, I found this to work:

Grid Setup:
<div id="example" class="k-content">
 
           <h3>Grid with only one column sorting enabled</h3>
           <div id="singleSort" style="width:600px;"></div>
 
       </div>
 
Sample Script:
<script>
$(document).ready(function() {
 
    $("#singleSort").kendoGrid({
        dataSource: {
            data: [{
                FirstName: "FirstName1",
                LastName: "LastName1"},
            {
                FirstName: "FirstName1",
                LastName: "LastName2"},
            {
                FirstName: "FirstName3",
                LastName: "LastName3"},
            {
                FirstName: "FirstName1",
                LastName: "LastName4"}],
        },
        groupable: false,
        // this will remove the group bar
        sortable: true,
         
        columns: [
                    {
                        field: "FirstName",
                        title: "First Name",
                        sortable: true,
                    },
                    {
                        field: "LastName",
                        title: "Last Name",
                        sortable: false  //note that if you do not set this to false, it will be true
                    },]
    });
});​
</script>

0
Joe
Top achievements
Rank 1
answered on 14 Feb 2012, 12:13 PM
Thanks!
Nihal
Top achievements
Rank 1
commented on 08 Jul 2021, 08:15 AM

in case all columns is sortable but i want sort by one column at a time i user select column the grid should be sorted by the selected column only and Remove the previous sort
Neli
Telerik team
commented on 12 Jul 2021, 11:02 AM

Sorting by single column is demonstrated in the Grid Sorting Demo linked below:

- https://demos.telerik.com/kendo-ui/grid/sorting

The sorting mode could be set to 'single' or 'multiple' by using the Grid sortable.mode option:

- https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/sortable.mode#sortablemode

Regards,

Neli

Bob
Top achievements
Rank 1
commented on 24 May 2023, 09:50 PM

Hi Neli,

Is there a cshtml code sample available? Something like this (below does not work):

<kendo-grid name="Grid">

        <no-records template="No data available." />        
        <columns>
            <column field="Id" hidden=true></column>
            <column field="Name" title="Name" width="100" sortable="true"></column>
            <column field="Phone" title="Phone Number" sortable="false"></column>
        </columns>
       
        <pageable enabled="true" />
        <sortable enabled="true" mode="single" />
        <scrollable enabled="true" />
    </kendo-grid>
Neli
Telerik team
commented on 29 May 2023, 01:00 PM

Hi Bob,

As far as I see form the provided snippet you need an example of using Kendo Grid with tagHelpers. If this is the case you can take a look at the dedicated demo that is part of the Telerik UI for ASP.NET Core suite demos:

https://demos.telerik.com/aspnet-core/grid/tag-helper

Also in the  Telerik UI for ASP.NET Core documentation the examples are demonstrated with HtmlHelpers and TagHelpers. You need to click on the needed tab to check the configuration with the tagHelpers

I hope this helps.

Regards,

Neli

Tags
Grid
Asked by
Joe
Top achievements
Rank 1
Answers by
Joe
Top achievements
Rank 1
Shannon
Top achievements
Rank 1
Share this question
or