nhn / tui.grid

🍞🔡 The Powerful Component to Display and Edit Data. Experience the Ultimate Data Transformer!
http://ui.toast.com/tui-grid/
MIT License
2.4k stars 386 forks source link

How to change each rows column type option in same grid #1972

Open ka-jiji opened 9 months ago

ka-jiji commented 9 months ago

I use Tui-grid version 3.7.0 with Javascript Here is my example. header : title | x1 | x2 0 check | radio | radio 1 write | text | text
2 check | radio | radio
3 write | text | text

 depend on title's value i want change columns options. 
 if title == "check" i want make x1,x2 columns are radio type
 if title == "write" i want make x1,x2 columns are text type.
 I want to change the columns option each rows. But i can't find the way.

var gd1_1 = grid1_1.getRows();
var gd1_1c = grid1_1.getColumns();
var options = [
    {
        text: "합격",
        value: "Y"
    },
    {
        text: "불합격",
        value: "N"
    }
];

for (var rowIndex = 0; rowIndex < gd1_1.length; rowIndex++) {
    var stitle_tpValue = gd1_1[rowIndex][itmobj2["stitle_tp"]];
    var x1Column = gd1_1c.find(column => column.name === itmobj2["x1"]);

    if (stitle_tpValue == "4") {
        x1Column.editOptions = {
            type: "radio",
            useViewMode: false,
            listItems: options
        };
    } else if (stitle_tpValue == "3") {
        x1Column.editOptions = {
            type: "text",
            useViewMode: false
        };
    }
}
grid1_1.setColumns(gd1_1c);

I tried with this code but this code makes every rows change with the last options. Kindly help me