0

如果它是唯一值,bootgrid 将使用非数字列 ID 作为标识符吗?

<th data-column-id="mytextid" data-identifier="true">Unique Text ID</th>

例如, selection="true" 会起作用吗?还是我需要标识符列的数值?

4

1 回答 1

2

好的,在小提琴中试了一下。您可以有一个非数字数据标识符。(恕我直言,它应该被称为数据行标识符......)

为了访问该列,您只需使用您在 data-column-identifier 中设置的名称,因此:

        <!-- works!! even without data-type="numeric" -->
        <th data-column-id="myid" data-identifier="true">My ID</th>
        <th data-column-id="info">Info</th>
    </tr>
</thead>

并且代码应该是

    $("#mygrid").bootgrid(
    {
        // other settings... and: 
        selection: true
    }).on("selected.rs.jquery.bootgrid", function(e, rows)
    {
        alert("Selected: " + rows[0].myid);
    });

这是一个 jsfiddle 来证明这一点

于 2015-10-18T22:23:42.380 回答