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
455
Add New Row and ValueList
posted

Hi,

I have a grid which display a AddNewRow row on the top of the grid to add a new row to the grid. Once of the column of the new row is a drop down so that user is restricted to select value from the list. My requirement is once the row is added the column with drop down should be not editable.

I have done few thing but not a perfect solution,

in the InitializeLayout method I set the column style as DropDownList and set it ValueList. and then in BeforeRowActivate method i added following code.

 

            if (e.Cell.Row.IsAddRow)
            {
                e.Cell.Row.Cells["COL_VLIST"].Activation = Activation.AllowEdit;
            }
            else
            {
                e.Cell.Row.Cells["COL_VLIST"].Activation = Activation.NoEdit;
            }

 

 

 

Another approached I used is in AfterRowInsert method I set the Cell ValueList, but it retain this valuelist after row is added to the grid?

What is the best way to handle this situation? Also another issue is when I am entering value in the new row anc click the down arrow the row is added to the grid, is there way so that I can validate teh value before row is added to the grid?

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi,

    I'm not sure I understand what you are asking.

    If you want the cell to be editable in the AddRow, but not in any other rows, then it seems like you should be able to handle this in the InitializeRow event and you don't really need any other event handlers.

    dverma said:
    Another approached I used is in AfterRowInsert method I set the Cell ValueList, but it retain this valuelist after row is added to the grid?

    I can't see any reason why the cell would not maintain the ValueList. But I don't think this is a good approach. It would be better to assign the ValueList to the column. This is especially important if the field is a key field where you are translating the data value into some display text.

    dverma said:
    What is the best way to handle this situation? Also another issue is when I am entering value in the new row anc click the down arrow the row is added to the grid, is there way so that I can validate teh value before row is added to the grid?

    I don't understand. Do you mean the dropdown button? Or the down arrow on the keyboard?

    Neither of these should be adding a new row to the grid.

Reply Children