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
4341
Xamdatagrid Performance Issue
posted

We are facing performance issue in the xamdatagrid (version 14.2). We found that the 'UpdateLayout' and the 'PerformAutosize' methods that we have used take lot of time, the time taken to load the grid is even more when the grid has large data.

 For resizing the columns we have used PerformAutosize for each field/column. Just wanted to know is there any way to do resize all the columns of the grid in one go without having to call the PerformAutosize for each column?

We also have another requirement according to which we want to change the color of the cells depending on the value of the cell. For achieving this, in the code behind we have created a style and trigger and have applied the same on each cell. Following is the code snippet that we have used for creating the style and the trigger. In our grid we have more than 1000 columns (number of columns displayed in the grid may vary, as these columns are generated dynamically). Depending on the number of columns the grid loading performance goes down considerably. We wanted to know is there any other way we can dynamically change the color of the cell without applying the trigger or if you can suggest any change in the below code that could help minimize the time of loading the grid.

 foreach (Field f in xamDataGrid1.FieldLayouts[0].Fields)

{

        f.DataType = typeof(decimal);

        f.ToolTip = "FY: " + f.Name.Replace("-", "");

         Style myStyle = new Style(typeof(CellValuePresenter), objBasedOnStyle);

         int k = (f.Index + (iFieldCount / 2));

        Binding b = new Binding("Cells[" + k + "].Value");

        DataTrigger dtgr = new DataTrigger();

        dtgr.Binding = b;

        dtgr.Value = "TRUE";

        dtgr.Setters.Add(new Setter(CellValuePresenter.BackgroundProperty, Brushes.Aqua));

        myStyle.Triggers.Add(dtgr);

         f.Settings.CellValuePresenterStyle = myStyle;

}