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
20
Making an input cell read-only dependent on another cell's value
posted

Hi!

I apologise if this is answered elsewhere, but I am new to Infragistics.

I have a WebDataGrid, where I'm entering a Priority (2 digit number) as cell(1).  In cell(3), there is a flag that says whether the row is to be edittable or not (Y or N).  What I'd like is in the Initialize code, to set the "ReadOnly" or "Enabled" aspect of item(1) depending on whether cell(3) is Y or N.

If it's Y, then leave the cell(1) as it is defined (edittable, user can put a number there and amend it).  However, if it's a N, I want that cell to be read-only (or even invisible).

I have tried all kinds of code, to no avail. The closest is:

        

for (i = 0; i < sender.get_rows().get_length(); i++)

         {

            

if (sender.get_rows().get_row(i).get_cell(3).get_value() == "N")

             {

                      sender.get_rows().get_row(i).get_cell(1).get_element().disabled = true;

      }

 

However, all this seems to do is grey-out the input field when cell(3)='Y', but I am still able to amend the value contained in it. I have tried things such as ".set_readonly", ".set_enabled", "_setReadOnly", but these cause the processing to terminate.

 

Help!  Thank you.

Parents
No Data
Reply
  • 2783
    posted

    Hi,

    Handle the EnteringEditMode client event of off the CellEditing behavior and in the event handler do the following:

           

            function enteringEditModeHandler(grid, args)

            {

                var cellElement = args.getCell().get_element();

                if (cellElement.disabled)

                    args.set_cancel(true);

            }

     

    Thanks

    Olga

Children
No Data