Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
440
Sort not refreshing on ultradropdown on ultragrid.
posted

I have an  ultragrid with a column whose ValueList is set to an ultradropdown. The dropdown has 2 visible columns - clientname and clientcode.

I have a button on the form which changes the DisplayMember of the dropdown (this is for autocomplete).

I am trying to change the sort order on the datasource for the dropdown, but I am unable to get it to refresh - the sort order is always set to clientname. i.e:

dropdown.Datasource = dataSet.Table.DefaultView; ... ...

dataSet.Table.DefaultView.Sort = "ClientCode ASC"; (this sorts the data OK in the dataset view)

Here's what I have tried so far:

using dropDown.DisplayLayout.Bands[0].SortedColumns.RefreshSort(false);

using dropDown.DisplayLayout.Bands[0].SortedColumns.RefreshSort(true);

using BeginUpdate/SuspendRowSynchronisation etc on the dropdown.

calling dropDown.DataBind() (this un-hides all the columns and messes with the widths).

Re-assigning the dropdown to the column's ValueList.

Re-assigning the datasource on the dropdown.

dropDown.SetDatabinding(dataSet.Table.DefaultView, "clientcode");

Thanks for any help!

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

    The BindingManager in DotNet does not notify bound controls when the sort order is changed. There's really no connection between the order of items in the DefaultView and the order of the items in the dropdown (or any control), except when they are initially bound.

    If you want to sort the items in the dropdown, then I recommend doing it on the dropdown itself, not on the data source. So you would use something like:

    dropdown.DisplayLayout.Bands[0].SortedColumns.Add(columnKey, false);

    If you must sort the data on the data source, then try calling dropdown.Rows.Refresh. There are a few different options for this method, and one of them might work, although I suspect it won't.

    The only other option is to call DataBind, which as you noticed, loses all of the state information and the layout. You could save the layout to a stream and then call data bind and then re-load the layout, which would, at least, maintain the original layout like the column widths.

     

Reply Children
No Data