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
30
Based on some specific condition I am trying to disallow add new / delete in hierarchical grid's sub grid
posted

Hello,

I am implementing a functionality using UltraWinGrid and not able to accomplish what I want.

My Infragistics Version details are: Infragistics4, Version 14.1

Here is the diagrammatic illustration what I actually want as below:

------------- --------------------
| Employee ID | Employee Name |
------------- --------------------
| ........... | .................. | <- Add New Row TemplateOnTop Visible (Based on some condition)
------------- --------------------
| Emp01 | Employee Name 1 |
------------- --------------------
--------------- ------------------------------
| Department ID | Department Name |
--------------- ------------------------------
| ............. | ............................ | <- Add New Row TemplateOnTop Visible (Based on some condition)
--------------- ------------------------------
| Dept01 | Department Name 1 | <- All rows are enabled (Based on some condition)
| Dept02 | Department Name 2 |
| Dept03 | Department Name 3 |
--------------- ------------------------------
------------- --------------------
| Emp02 | Employee Name 2 |
------------- --------------------
--------------- ------------------------------
| Department ID | Department Name |
--------------- ------------------------------ <- Add New Row TemplateOnTop Hidden (Based on some condition)
| Dept04 | Department Name 4 |<- All rows are disabled (Based on some condition)
| Dept05 | Department Name 5 |
| Dept06 | Department Name 6 |
--------------- ------------------------------
------------- --------------------
| Emp03 | Employee Name 3 |
------------- --------------------
--------------- ------------------------------
| Department ID | Department Name |
--------------- ------------------------------
| ............. | ............................ | <- Add New Row TemplateOnTop Visible (Based on some condition)
--------------- ------------------------------
| Dept07 | Department Name 7 | <- All rows are enabled (Based on some condition)
| Dept08 | Department Name 8 |
| Dept09 | Department Name 9 |
--------------- ------------------------------

Based on some specific condition I am trying to disallow add new / delete in hierarchical grid's sub grid's. But when I am trying doing it on InitializeRow event of the grid using 

e.Row.Band.Layout.Override.AllowAddNew = AllowAddNew.No;
e.Row.Band.Layout.Override.AllowDelete = DefaultableBoolean.False;

and to show/enable:
e.Row.Band.Layout.Override.AllowAddNew = AllowAddNew.TemplateOnTop;
e.Row.Band.Layout.Override.AllowDelete = DefaultableBoolean.True;

Whole grid's Add New Row functionality stop working. I tried Googeling but did not found anything helpful.

Please let me know how can I achieve it.

Thank You!
Parents
No Data
Reply
  • 28945
    Offline posted

    Hello, 

    Thank you for contacting Infragistics. You can use the InitializeTemplateAddRow event to suppress the add row from appearing within certain child rows. 

    eg. 

    private void ultraGrid1_InitializeTemplateAddRow(object sender, Infragistics.Win.UltraWinGrid.InitializeTemplateAddRowEventArgs e)
            {
                // Do not allow adding to the child band based on the parent row. Just
                // for purposes of example, we will disallow adding on parent rows where
                // the first column value is an odd number.
                if (e.TemplateAddRow.Band.Key == "Band 1")
                {
                    var parentRow = e.TemplateAddRow.ParentRow;
                    int value = (int)parentRow.GetCellValue("Column 0");
                    if (value % 2 == 1)
                    {
                        e.TemplateAddRow.Hidden = true;
    
                        // You could also disable the row, instead of hiding it, but this is
                        // a little weird, since there's no text in the row and it's hard to 
                        // see that it's disabled. 
                        //e.TemplateAddRow.Activation = Infragistics.Win.UltraWinGrid.Activation.Disabled;
                    }
                }
            }

    Please see the sample below for more details. 

    WindowsFormsApplication53.zip

Children
No Data