Question T12744
Visible to All Users

Matrixdropdown have add row to add data will dropdown and text values

created 2 years ago

Clipboard-File-1.png

this is my current screen which has details of list of items in table.
Now there is a requirement where on Add row new row should be added but it should have two text boxes Min & Max and the Column1 should be dropdown selection on whose selection it should add the value.
Clipboard-File-2.png

Show previous comments (30)

    Hello,
    You set the matrix dynamic value incorrectly. It's value is an array.
    Here is the example.

    Thank you,
    Andrew
    SurveyJS Team

      Hi Andrew,
      Thanks for the correction.
      But here the matrix row will be added dynamically so we cannot set that like this seems to be static only.
      I means there can be 2 row or more than two also on the basis of dropdown selection.
      I want whenever I add a new row it should set the values for these.
      Also, i need remove row also.

        Hello,
        You can use matrix.addRow and matrix.removeRow functions.
        As another option. You can get the previous matrix value, modify it as you need and then set it back:

        JavaScript
        let val = matrix.value; if(!Array.isArray(val)) val = []; //Delete the third row val.splice(2, 1); //Add a new row into the end of array val.push({ min: 1, max: 3}); //Insert as a first row val.push({ min: 1, max: 3}); matrix.value = val;

        Thank you,
        Andrew
        SurveyJS Team