Custom Table Selector Ordering

Kieran O'Callaghan asked on December 13, 2018 15:24

Hi,

I have added a Custom Table Selector to a Webpart.

All working as expected except the order of the items in the drop down list. Is there a way to order the drop down list items by the Text in the list.

Thanks K.

Recent Answers


Peter Mogilnitski answered on December 13, 2018 15:53 (last edited on December 13, 2018 21:43)

It doesnt exist , but you can clone the existing form control (~/CMSModules/CustomTables/FormControls/CustomTableItemSelector.ascx). Add new field OrderBy(in the database and in the code) and in CustomTableItemSelector.ascx.cs you do something like:

    // you custom property
    public string OrderBy
    {
        get
        {
            return ValidationHelper.GetString(GetValue("OrderBy"), null);
        }
        set
        {
            SetValue("OrderBy", value);
            uniSelector.OrderBy = value;
        }
    }

  ...

  public void ReloadData()
    {
        uniSelector.IsLiveSite = IsLiveSite;
        ....
        uniSelector.OrderBy =  OrderBy
        ...
        uniSelector.Reload(false);
    }
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.