Setting column data type for sorting

Posted by: tobyschlank on 1 September 2019, 1:43 pm EST

    • Post Options:
    • Link

    Posted 1 September 2019, 1:43 pm EST

    Hi,

    I am using VB.Net and ComponentOne 2017.2.1.5. I am using Flexgrid.

    Is there a way to set the column data type (number, int, date, datetime) of the columns so that sorting works properly when the user clicks the column headings?

    Thanks

  • Posted 1 September 2019, 6:15 pm EST

    Hello,

    You can use the DataType property of the RowCol class to set the DataType for the particular column.

    So that on clicking the header of the particular column, the data sorted according to the datatype of that column.

    To learn more about this property you can refer to the links given below :

    https://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#C1.Win.C1FlexGrid.4~C1.Win.C1FlexGrid.RowCol~DataType.html

    https://help.grapecity.com/componentone/NetHelp/c1flexgrid/webframe.html#step2of6setcolumntypesandformats.html

    If you need any other help, please let us know.

    Regards,

    Prabhat Sharma.

  • Posted 2 September 2019, 12:57 pm EST

    Thanks for your reply.

    Do you have an example of this?

    Thanks.

  • Posted 2 September 2019, 6:27 pm EST

    Hello,

    When the grid is bound to a data source, this property is set automatically based on the data schema.

    When we use FlexGrid in Unbound mode, we need to set it in the code.

    Please find the attached sample demonstrating the same.

    If you need any other help, please let us know.

    Regards,

    Prabhat Sharma

    C1FlexGridDataTypeDemo.zip

  • Posted 10 September 2019, 11:15 am EST

    Sorry for late reply.

    When i try to integrate the datatype part into my project, i get the following errors:

    ‘String’ is a class type and cannot be used as an expression

    ‘int32’ is a type and cannot be used as an expression

    ‘datetime’ is a type and cannot be used as an expression

    Thanks

  • Posted 10 September 2019, 6:15 pm EST

    Hello,

    I didn’t face such type of error when setting the Datatype of a column.

    Please modify the last attached sample or provide your stripped down sample replicating the issue so that we can narrow down the problem at our end and provide you a solution.

    Regards,

    Prabhat Sharma.

  • Posted 11 September 2019, 5:52 pm EST - Updated 3 October 2022, 3:49 pm EST

    When i try to use this in VB.Net, i get the attached…



    Thanks

  • Posted 11 September 2019, 9:00 pm EST

    Hello,

    Please use the code snippet given below to set the columns’ DataType in VB project :

    a.Cols(1).DataType =  GetType(String)
    a.Cols(1).DataType =  GetType(Int32)
    a.Cols(1).DataType =  GetType(DateTime)
    

    I hope it helps.

    Regards,

    Prabhat Sharma.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels