Item Formatting in the .Net 6 .0 WPF Flexgrid

Posted by: rambabu on 15 May 2023, 6:01 am EST

    • Post Options:
    • Link

    Posted 15 May 2023, 6:01 am EST

    Hello,

    I have a requirement to show a check box or Textblock in the WPF flex grid column based on a few conditions. can you please let me know how to implement this?

    do we have any methods like item formatter similar to what we have on the web (wijmo)?

  • Posted 16 May 2023, 5:29 pm EST

    Hi Rambabu,

    You can extend Flexgrid’s GridCellFactory class to create checkbox or textblock in a column based on some conditions. We have created a sample application for your reference where have created Checkbox/textblock control in the last column of the flexgrid by applying some condition on the price column. We have to override GridCellFactory’s GetCellContentType, CreateCellContent, BindCellContent and UnbindCellContent method to implement the functionality.

    Kindly refer to ConditionalCellFormatting.zip

    Please let us know if you have any further concerns regarding this.

    Thanks & Regards,

    Aastha

  • Posted 25 May 2023, 4:39 am EST

    Hello Aastha,

    I tried to implement using the GridCellFactory, but I am facing an issue with formatted column values, the cell values are changing when I have a vertical scrollbar and when I scroll down to the grid, I attached a video for reference and the code used for formatting.

    Please let me know how to resolve the issue

    https://www.awesomescreenshot.com/video/17740959?key=ab1d33e743c0b84dc6191de8037d97aa

    ConditionalFormatting.xaml.zip

  • Posted 26 May 2023, 9:56 pm EST

    Hi Rambabu,

    Thanks for providing the sample.

    We are analyzing your sample and working towards the solution of your issue. We will update you soon on this.

    Thanks & Regards,

    Aastha

  • Posted 29 May 2023, 12:32 am EST

    Hi Rambabu,

    In the provided XAML code, there is a column named ‘Test’ with its Binding property set to “Test”. However, if the Customer class does not currently contain a property named “Test”, it seems that an update to the data model is necessary.

    If you have not added a property named “Test” to the Customer class, we have made a modification to the XAML code as follows:

    <c1:GridColumn Header="Test" Format="N1"/>

    However, if you have indeed made changes to the data model and added a “Test” property, please provide the relevant code so that I can assist you further.

    In your application, you are creating a checkbox column. It is advisable to utilize XAML data templates to define the cell template for bound columns. For more detailed information on how to implement this approach, you can refer to the provided resource.

    *https://www.grapecity.com/componentone/docs/wpf/online-flexgrid/CellTemplateandCellEditingTemplate.html

    The CreateCellContent method is responsible for generating the content of a cell, while the BindCellContent method is used to set the actual data in the cell. However, since the data in your custom column is not bound, it is recommended to override the PrepareCell() method instead. This method is invoked for all the cells within the viewport and allows you to create the cell view accordingly. By overriding PrepareCell(), you can customize the cell’s appearance and content based on your specific requirements.

    Kindly refer to the attached sample for full implementation. ( See CheckBoxColumnNET6.zip)

    Please let us know if you have any further concerns regarding this.

    Thanks & Regards,

    Aastha

  • Posted 5 June 2023, 2:39 am EST

    Hello Aastha,

    Thank you for the solution, I modified the solution provided by you a little bit and found this issue is still happening, can you please let me know how to address this?

    CheckBoxColumnNET6.zip

    https://www.awesomescreenshot.com/video/18043113?key=d0f0e158c4d18d5a3e48bc5646b8ed19

  • Posted 6 June 2023, 6:28 am EST

    Hi Rambabu,

    We have updated the GetCellContentType and BindCellContent method in the sample provided by you. Since, you have created checkbox in “OrderCount” column you have to update the cell content accordingly in the methods of GridCellFactory class.

    Please refer CheckBoxColumnNET6_Mod.zip

    Hope you find this sample helpful. Kindly let us know if you have any further issues regarding this.

    Thanks & Regards,

    Aastha

  • Posted 9 June 2023, 1:10 am EST

    Thank you Aastha

Need extra support?

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

Learn More

Forum Channels