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
200
Performance issue to expand all records
posted

Hi,

I have bound 2 hierarchic tables with high volume data (approx. 5000 rows in first table and 25000 rows in second table)  within the xamdatagrid. I want to select one row in the second table programmatically. If the row is found by ID and I want to set the row active and I want to expand the parent data record. The code takes a lot of time only for the first time.

Also using Records.ExpandAll takes really a lot of time.

Do you have any idea how to enhance the performance?

Thanks a lot and best regards Jan

private static bool SelectRecord(XamDataPresenter datagrid, IEnumerable<Record> records, int index, string viewlevel)

        {

            bool result = false;

            try

            {

                foreach (var record in records ?? Enumerable.Empty<Record>())

                {

                    if (record.ViewableChildRecords != null && record.ViewableChildRecords.Count > 0)

                        if (SelectRecord(datagrid, record.ViewableChildRecords, index, viewlevel) == true)

                            break;

 

                    if (viewlevel == (string)record.FieldLayout.Key)

                    {

                        DataRecord datarecord = (record as DataRecord);

                        if (datarecord != null)

                        {

                            var dataitem = datarecord.DataItem;

                            if (dataitem != null)

                            {

                                int id = (int)datarecord.Cells["ID"].Value;

                                if (id == index)

                                {

                                    if (record.Visibility == Visibility.Visible)

                                    {

                                        datagrid.ActiveRecord = record;

                                        if (datagrid.ActiveRecord.ParentDataRecord != null)

                                        {

                                            datagrid.ActiveRecord.ParentDataRecord.IsExpanded = true;

                                            datagrid.BringRecordIntoView(datagrid.ActiveRecord);

                                            result = true;

                                            break;

                                        }

                                    }

                                }

                            }

                        }

                    }

 

                }

            }

            catch (Exception ex)

            {

                System.Diagnostics.Debug.WriteLine(ex.ToString());

                return result;

            }

            return result;

        }

Parents Reply Children
No Data