方法如下
const $grid = xGrid.value;
const selectRecords = $grid?.getCheckboxRecords(true)
这里的getCheckboxRecords()用于 type=checkbox的行,获取当前已选中的行数据,参数为true 则获取全表已选中的数据。
它获取到的数据是这样的:
上图是选中两行时获取到的数据,这是一个长度为2的对象数组。
因此,可以使用selectRecords[0].id获取具体的数据项(例如id)。