Add a input control into every grid row

is there possible to add an input control into every grid row at runtime?

Thanks
Teo

Which Grid control are you using? (From which framework)

1 Like

It is common grid that i talk about

Thanks
Teo

Here’s the basic principle. You’ll need to work out all the spacing and formatting.

What we do is take an Input element which is already in your project called Input1. We clone it and add it to each cell. We also set the ID for the new input so we can reference it.

JavaScript

Button1.onclick = function() {
  for (row = (1); row  <= 4; row ++) {
    Grid1.setValue(row, 0, row);
    clone = Input1.cloneNode(true);
    clone.id = "GridInput" + row;
    NSB.$("Grid1_"  +  row  +  "_1").appendChild(clone);
  }
};

BASIC

Function Button1_onclick()
  For row = 1 To 4
    Grid1.setValue(row, 0, row)
    clone = Input1.cloneNode(True)
    clone.id = "GridInput" + row
    NSB.$("Grid1_" & row & "_1").appendChild(clone)
  Next
End Function

JavaScript

I am managed to append the input into a grid, however

  1. how can i get the clone input’s properties.
    clone=Input1.cloneNode(True)
    clone.id=“input2”
    NSB.("frcustord_gdtrx_1_2").appendChild(clone); NSB.(“input2”).hidden=False //no working
  2. And since the are many clone inputs into a grid row, how can i get the correct clone input value when one of the clone input is onchange

Thanks
Teo

Notice how clone.id is set?

clone.id = "GridInput" + row

The input fields are then named GridInput1, GridInput2,…

In your statement

NSB.("frcustord_gdtrx_1_2").appendChild(clone); NSB.(“input2”).hidden=False //no working

You are missing a $ in the 5th position.

The event called for the on change will be GridInput1_onchange.

Here is the no working sample, i have a input (input1) with hidden = true

If results.rows.length>0 Then
For i=0 To results.rows.length - 1
  r=i + 2
  clone=Input1.cloneNode(True);
  clone.id="input" + r;
   NSB.$("grid_" + i + "_2").appendChild(clone);
   NSB.$("input" + r).hidden=False;
next
end if

the cloned input are managed to added into each row, however all cloned inputs become visible after i set input1.hidden = false

secondly, since cloned input is a variable value, how can i write an event to cater all input on change

Thanks
Teo