hide/show column client-side by uniquename or datafield

3 posts, 0 answers
  1. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 03 Jan 2017 Link to this post

    I know you can hide columns client-side using masterTableView.hideColumn(columnIndex). However, this leads to very difficult to maintain code since column ordinals can change frequently. Is there a way to find a column by UniqueName or DataField client side and then call .hide() or show() functions, or set_visible() , or something to that effect?
  2. Ben
    Ben avatar
    4 posts
    Member since:
    May 2016

    Posted 03 Jan 2017 in reply to Albert Shenker Link to this post

    You should be able to use the method described in the following post to get the column's index by unique name, then call the hideColumn() method using the found index.

    Source: http://www.telerik.com/forums/how-to-get-column-index-from-column-name-at-client-side

     

    Modified function:

    function hideColumnByUniqueName(columnName) {
        var masterTableView = $find('<%= RadGrid1.ClientID %>').get_masterTableView();
        var column = masterTableView.getColumnByUniqueName(columnName);
        var element = column.get_element();
        masterTableView.hideColumn(element.cellIndex);
    }

     

    Hope this helps

  3. Albert Shenker
    Albert Shenker avatar
    579 posts
    Member since:
    Mar 2004

    Posted 03 Jan 2017 in reply to Ben Link to this post

    Thanks. That seems to have worked. Hopefully they'll just add hide/show methods to the column object at some point in the future.
Back to Top