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
340
Sort date column
posted

I have filled ultragrid using datatable which contains two date columns From and TO. But when i click on the From column, the data is not getting sorted correctly.

In Initailise layout evebt, i have written the below code,
 e.Layout.Bands(0).Columns("From").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date
        e.Layout.Bands(0).Columns("To").Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date

can anyone please help me out form this issue.

Thank you

  • 20872
    Offline posted

    Hello Sweish,

    I am still following this forum thread.

    Please feel free to let us know if you have any other questions with this matter.

     

  • 20872
    Offline posted

    Hello Sweish,

    I have tried what you are describing above using the NetAdvantage for WinForms 2011 vol2 but it seems to work correctly for me. Could you please let me know what version of the Infragistics controls you are using in your application?

    I have used the code snippet below to verify the mentioned behavior at my end. Could you please try it and let me know if you are still getting incorrect sorting of the Dates in the UltraGrid?

         public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                DataTable dt = new DataTable();
                dt.Columns.Add("From", typeof(DateTime));
                dt.Columns.Add("To", typeof(DateTime));

                dt.Rows.Add(DateTime.Today.AddDays(-10).AddHours(11), DateTime.Today.AddDays(-10).AddHours(12));
                dt.Rows.Add(DateTime.Today.AddDays(-9).AddHours(10), DateTime.Today.AddDays(-9).AddHours(11));
                dt.Rows.Add(DateTime.Today.AddDays(3).AddHours(7), DateTime.Today.AddDays(3).AddHours(9));
                dt.Rows.Add(DateTime.Today.AddDays(-8).AddHours(5), DateTime.Today.AddDays(-8).AddHours(6));
                dt.Rows.Add(DateTime.Today.AddDays(4).AddHours(6), DateTime.Today.AddDays(4).AddHours(8));
                dt.Rows.Add(DateTime.Today.AddDays(6).AddHours(7), DateTime.Today.AddDays(6).AddHours(9));
                dt.Rows.Add(DateTime.Today.AddDays(1).AddHours(1), DateTime.Today.AddDays(1).AddHours(3));
                dt.Rows.Add(DateTime.Today.AddDays(5).AddHours(3), DateTime.Today.AddDays(5).AddHours(4));
                dt.Rows.Add(DateTime.Today.AddDays(-2).AddHours(4), DateTime.Today.AddDays(-2).AddHours(6));

                ultraGrid1.DataSource = dt.DefaultView;
            }

            private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
            {
                e.Layout.Bands[0].Columns["From"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date;
                e.Layout.Bands[0].Columns["To"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.Date;
            }
        }

    If you have any other questions please feel free to ask.