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
635
Sorting on a hidden field fails
posted

Hi,

I've a column in a grid holding an image (index =0) representing state an image which when the sort is triggered should sort on a hidden column (index =3).

protected void ColumnSorted(object sender, SortingEventArgs e)
    {
        if (e.Column.Index != 0)
        {       
            RepopoulateScreenVariables();
            this.gridTranslations.DataSource = _AfterDataTableGrid.DataTableView;
            this.gridTranslations.DataBind();    
        }
        else        
        {
            //try to create a new Event that clicks the 3rd column/Status
            //then recall this function
            e = new SortingEventArgs(
                        new SortedColumnInfoCollection(this.gridTranslations),
                        this.gridTranslations.Columns[3]);
            Column_Sort(sender, e);
 
        }
    }

However, when it recalls the function with the new event arg it fails, I'm assuming this is because the event has fired after the sorting has occurred.

I can't seem to find an example/way of redirecting the column click.

Does anyone have any ideas?

Cheers

  • 29417
    Suggested Answer
    Offline posted

    Hello murray7

    Thank you for posting in our forum. 

    You can cancel the default sorting by clearing the sorted columns collection and adding your own column to sort by after that . For example:

     

    protected void WebDataGrid1_ColumnSorted(object sender, Infragistics.Web.UI.GridControls.SortingEventArgs e)

        {

            if (e.Column.Index == 1)

            {

             

                e.SortedColumns.Clear();

                e.SortedColumns.Add(this.WebDataGrid1.Columns[0],Infragistics.Web.UI.SortDirection.Descending);

            }

            this.WebDataGrid1.DataSource = MakeTable();

           

        }

     

    In this case if the sorted column is with index 1 then cancel the default sorting and sort the column with index 0 in descending order. 

    Also if you’re not providing the data source anywhere else in the page lifecycle then you need to do it in that even so that you’ll have a  data source each time you sort.

     

    Let me know if you have any questions or concerns.

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://es.infragistics.com/support