NTreeList Sortable NTreeListColumn property issue


https://www.nevron.com/Forum/Topic6881.aspx
Print Topic | Close Window

By Craig Swearingen - 12 Years Ago

I'm using the NTreeList with build 11.12.14.12.  One of my columns is specified like this:

col = new NTreeListColumn();

col.Width = 25;

col.Name = COLUMN_COUNTRYIMAGE;

col.Header.Text = string.Empty;

col.Sortable = false;

tl.Columns.Add(col);

The column shows images on the nodes and the column header is blank.  Though I've specified Sortable to be false when the user clicks on that column header it will highlight the column and show the appropriate ascending/descending glyph.  How do I stop this sort activity from being allowed?

By Nevron Support - 12 Years Ago
Hello Craig,

You need to attach to NTreeList.ColumnNotify event and in the event handler to do the following:

void nTreeList1_ColumnNotify(object sender, NTreeListColumnNotifyData data)
{
   if (data.NotifyCode == NTreeList.ColumnSortingNotifyCode)
   {
      data.Cancel = true;
   }
}

If you need this only for certain column(s) you need to check the column along with the notify code:

if (data.NotifyCode == NTreeList.ColumnSortingNotifyCode && data.Column == col) ...
By Craig Swearingen - 12 Years Ago

Thanks, that worked.  So I set it like this:

private void TreeList_ColumnNotify(object sender, NTreeListColumnNotifyData data)

{

if ((data.NotifyCode == NTreeList.ColumnSortingNotifyCode) && !data.Column.Sortable)

{

data.Cancel = true;

}

}

Please let me know if I should not use the Sortable property like this.

By Nevron Support - 12 Years Ago
You can use Sortable to check whether the column can be sorted, but you need first explicitly set this property for the desired columns.