Prevent Specific column from re-ordering

13 posts, 0 answers
  1. A
    A avatar
    1 posts
    Member since:
    Oct 2012

    Posted 22 Oct 2012 Link to this post

    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 ?

  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 26 Oct 2012 Link to this post

    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!
  3. Suril
    Suril avatar
    3 posts
    Member since:
    Sep 2012

    Posted 07 Nov 2012 Link to this post

    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?
  4. Giovanni
    Giovanni avatar
    37 posts
    Member since:
    Feb 2011

    Posted 30 Jan 2013 Link to this post

    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.
  5. Ryan
    Ryan avatar
    61 posts
    Member since:
    Mar 2014

    Posted 12 Mar 2014 Link to this post

    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);
        }
    }
  6. Ryan
    Ryan avatar
    61 posts
    Member since:
    Mar 2014

    Posted 12 Mar 2014 in reply to Ryan Link to this post

    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);
        }
    }
  7. donig
    donig avatar
    8 posts
    Member since:
    Jun 2012

    Posted 01 Sep 2015 Link to this post

    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.

     

  8. Gabe
    Gabe avatar
    1 posts
    Member since:
    Aug 2015

    Posted 19 Nov 2015 in reply to donig Link to this post

    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);
    }

  9. Raj Kumar
    Raj Kumar avatar
    1 posts
    Member since:
    Jun 2017

    Posted 12 Jun 2019 Link to this post

    Kendo has released a workaround for this.

     

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

  10. John
    John avatar
    7 posts
    Member since:
    May 2018

    Posted 10 Mar in reply to Raj Kumar Link to this post

    it looks like kendo used the previous person's code and added to their wiki.  This is not any kind of new "release".
  11. Tsvetomir
    Admin
    Tsvetomir avatar
    837 posts

    Posted 15 Mar Link to this post

    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/.

  12. John
    John avatar
    7 posts
    Member since:
    May 2018

    Posted 15 Mar in reply to Tsvetomir Link to this post

    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".

     

  13. Tsvetomir
    Admin
    Tsvetomir avatar
    837 posts

    Posted 15 Mar Link to this post

    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.

Back to Top