Skip to Content
avatar image
Former Member

chaos in grid with rows which are collapsed and expanded

I have problem with collapse and expand functionality. I've added some rows and set on grid collapseLevel = 1.

Everything is displayed correctly and grouped as I expected but when i want to catch a row data I get data wich is incorrect. The problem is that when the data is grouped is ordered with a groups and clicking any row gives me other rows data.

For example when I click row 3 I get the data from row 2.

 Grid EqElemGrd = form.Items.Item(PhysicalPropertyFormulaForm.Controls.EquationElements.Grid).Specific;
            DataTable EqElemData = form.DataSources.DataTables.Item(PhysicalPropertyFormulaForm.DataSources.EquationElements.DataTable);
            EqElemData.Rows.Clear();


            Dictionary<string, string> functions = new Dictionary<string, string>();
            functions.Add("ABS(x)", "Returns the absolute value of x.");
            functions.Add("ACOS(x)", "Returns the arc cosine of x, in radians.");
            functions.Add("ASIN(x)", "Returns the arc sine ofx, in radians.");
            functions.Add("ATAN2(x; y)", "Returns ATAN(y/x) taking signs of x and y into account.");
            functions.Add("ATAN(x)", "Returns the arc tangent of x, in radians.");
            functions.Add("CEILING(x; signif)", "Returns the nearest multiple of signif");

            int i = 0;


            foreach (var func in functions)
            {


                EqElemData.Rows.Add();
                EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Type, i, "Function");
                EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Code, i, func.Key);
                EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Description, i, func.Value);
                i++;


            }




            EqElemData.Rows.Add();
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Type, i, "Global");
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Code, i, "TW");
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Description, i, "Total Formula Weight");
            i++;
            EqElemData.Rows.Add();
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Type, i, "Global");
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Code, i, "TV");
            EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Description, i, "Total Formula Volume");
            i++;


            QueryManager qm = new QueryManager();
            qm.SimpleTableName = "@CT_PF_OIPR";
            qm.SetSimpleWhereFields("U_FrlaPrp");
            qm.SetSimpleResultFields("U_FrlaType", "U_PrpCode", "U_PrpName");


            using (var result = qm.ExecuteSimpleParameters("", "Y"))
            {
                for (int k = 0; k < result.RecordCount; k++)
                {
                    EqElemData.Rows.Add();
                    string U_PrpCode = result.Fields.Item("U_PrpCode").Value;
                    string U_PrpName = result.Fields.Item("U_PrpName").Value;
                    string U_FrlaType = result.Fields.Item("U_FrlaType").Value;
                    EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Type, k + i, U_FrlaType);
                    EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Code, k + i, U_PrpCode);
                    EqElemData.SetValue(PhysicalPropertyFormulaForm.DataSources.EquationElements.Columns.Description, k + i, U_PrpName);


                    result.MoveNext();
                }
            }


            EqElemGrd.CollapseLevel = 1;
            EqElemGrd.Rows.CollapseAll();
Add comment
10|10000 characters needed characters exceeded

  • Could you share the code you use to get the data from the grid? As far as I understood this code is showing how you are filling the grid

  • Former Member
    public override void OnDoubleClickAfter(string FormUID, ref PItemEvent itemEvent)
            {
    
    
                if (itemEvent.ItemUID == PhysicalPropertyFormulaForm.Controls.EquationElements.Grid && itemEvent.Row != -1)
                {
                    
                    Form form = itemEvent.CurrentForm;
                    Grid ElementsBodyGrd = form.Items.Item(PhysicalPropertyFormulaForm.Controls.EquationElements.Grid).Specific;
                  
                    EditText EqBody = form.Items.Item(PhysicalPropertyFormulaForm.Controls.EquationBodyEditText).Specific;
    
    
    
    
                    EqBody.Value += ElementsBodyGrd.DataTable.GetValue(PhysicalPropertyFormulaForm.Controls.EquationElements.Columns.Code, itemEvent.Row);
    
    
                }
            }
    
  • Get RSS Feed

1 Answer

  • Best Answer
    Sep 18, 2017 at 03:40 PM

    Hi,

    The problem happened because when you collapse the grid, the rows are not the same as the datatable it is linked to, so you can use GetDataTableRowIndex to get the right row

    EqBody.Value += ElementsBodyGrd.DataTable.GetValue(PhysicalPropertyFormulaForm.Controls.EquationElements.Columns.Code, ElementsBodyGrd.GetDataTableRowIndex(itemEvent.Row));
    Add comment
    10|10000 characters needed characters exceeded