This is a migrated thread and some comments may be shown as answers.
Prevent Specific column from re-ordering
12 Answers 295 Views
This is a migrated thread and some comments may be shown as answers.
A
Top achievements
Rank 1
A asked on 22 Oct 2012, 09:35 PM
Hi,

I am trying to prevent a checkbox column (first column) on a gird from reordering, I overrided the grid-column-reorder event and tried the e.PreventDefault after checking the correct index value(s) with no luck what so ever. I even tried calling grid.reorderColumn with no luck too. 

Is there anyway I can prevent a specific column from reordering but allow other columns to reorder ?

12 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 26 Oct 2012, 06:45 AM
Hello,

The Grid does not allow such configuration. The re-size-ing feature could be either activated for all the columns or disabled.

Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Suril
Top achievements
Rank 1
answered on 07 Nov 2012, 09:07 AM
I have same requirement where we want to stop reordering on specific column of the grid.

Do any one have idea how to implement it?
0
Giovanni
Top achievements
Rank 1
answered on 30 Jan 2013, 04:05 PM
Hello,
I have also a first checkbox column.
I would like to prevent reordering and resize of the first column that must be a fix column.
Is it possible to obtain this behaviour? 
If not, do you plan to add this option? We would like to introduce Kendo Grid in our products, but without this option I don't know if the grid could be used in production..

Thanks.
0
Ryan
Top achievements
Rank 1
answered on 12 Mar 2014, 04:52 PM
I know this is old but stumbled across it and thought I'd share. This isn't provided out of the box but here's a simple solution:

In the columns definition add a reorderable: false property, and optionally a stickyPosition property (see onReorder).

columns: [
    { field: "check_row", title: " ", template: "<input class='check-row' type='checkbox' />", reorderable: false, stickyPosition: 0 },
    "ProductName",
    ...
]

Set a callback for the columnReorder event.

$("#grid").kendoGrid({ columnReorder: onReorder, ... });

This onReorder callback function below will place the column back to the stickyPosition column index, or 0 if not provided.

function onReorder(e) {
    if (typeof e.column.reorderable != "undefined" && !e.column.reorderable) {
        var grid = $('#grid').data('kendoGrid');
        setTimeout(function() {
            grid.reorderColumn(e.column.stickyPosition || 0, grid.columns[e.newIndex]);
        }, 0);
    }
}
0
Ryan
Top achievements
Rank 1
answered on 12 Mar 2014, 05:36 PM
Actually this is even easier than I first posted... No need for stickyPosition.

function onReorder(e) {
    if (typeof e.column.reorderable != "undefined" && !e.column.reorderable) {
        var grid = $('#grid').data('kendoGrid');
        setTimeout(function() {
            grid.reorderColumn(e.oldIndex, grid.columns[e.newIndex]);
        }, 0);
    }
}
0
donig
Top achievements
Rank 1
answered on 01 Sep 2015, 07:17 PM

The solution doesn't work fully. It only keeps you from moving a reorderable column. However, you can move another column that causes the "non-reorderable" column to move.

 

0
Gabe
Top achievements
Rank 1
answered on 19 Nov 2015, 08:57 PM

Assuming your nonreorderable column will be on the end you can use this: (it could be modified to look at columns between the range)

var grid = $(gridName).data('kendoGrid');
if (grid.columns[e.newIndex].reorderable === false || grid.columns[e.oldIndex].reorderable === false) {
    setTimeout(function () {
        grid.reorderColumn(e.oldIndex, grid.columns[e.newIndex]);
    }, 0);
}

0
Raj Kumar
Top achievements
Rank 1
answered on 12 Jun 2019, 02:56 PM

Kendo has released a workaround for this.

 

https://docs.telerik.com/kendo-ui/knowledge-base/grid-prevent-columns-reordering 

0
John
Top achievements
Rank 1
answered on 10 Mar 2021, 04:35 PM
it looks like kendo used the previous person's code and added to their wiki.  This is not any kind of new "release".
0
Tsvetomir
Telerik team
answered on 15 Mar 2021, 12:30 PM

Hi John,

It is correct that the Knowledge base articles are not included in the releases. Indeed, they are additional resources created when there is a demand for specific functionality and are not related to the releases.

I could also see that the Knowledge base has derived from another support ticket and not from the current thread. It also shows a highly simplified version.

If there is anything else I can help with, let me know.

 

Regards,
Tsvetomir
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
John
Top achievements
Rank 1
answered on 15 Mar 2021, 01:55 PM

do not misunderstand.  I did not have a problem with you doing that.  The previous poster said it was in a new release and i was merely saying "no it isn't.  It's just on the wiki".

 

0
Tsvetomir
Telerik team
answered on 15 Mar 2021, 03:40 PM

Hi John,

Thank you for taking the time to elaborate on your statement. If there is anything that I can help with, let me know.

 

Kind regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid
Asked by
A
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Suril
Top achievements
Rank 1
Giovanni
Top achievements
Rank 1
Ryan
Top achievements
Rank 1
donig
Top achievements
Rank 1
Gabe
Top achievements
Rank 1
Raj Kumar
Top achievements
Rank 1
John
Top achievements
Rank 1
Tsvetomir
Telerik team
Share this question
or