$('#manage_price_datagrid').datagrid('appendRow',{id:Date.now(),isTag:1})append后append的行不能被选中
时间: 2023-09-21 08:06:29 浏览: 42
可以在 `onAdd` 事件中遍历每一行数据,根据需要设置 `selectable` 属性来控制行是否可选中。示例代码如下:
```javascript
$('#manage_price_datagrid').datagrid({
// ...
onAdd: function(index, row) {
if (row.isTag === 1) {
// 设置行不可选中
$('#manage_price_datagrid').datagrid('getRowByIndex', index).selectable = false;
}
}
});
```
其中 `isTag` 是你新增行的某一列的名称,`1` 是你新增行中该列的值,你需要根据实际情况进行修改。
相关问题
var really_row = new Array(); var price_rows = $('#manage_price_datagrid').datagrid('getRows'); really_row = price_rows; for(var priceIndex in really_row){ if(really_row[priceIndex].isTag){ var deleteIndex= $('#manage_price_datagrid').datagrid('getRowIndex',really_row[priceIndex]) console.log(deleteIndex); $('#manage_price_datagrid').datagrid('deleteRow', deleteIndex); } }只删除了一条
这段代码看起来是在使用 jQuery EasyUI 的 Datagrid 控件进行数据操作。具体来说,代码中通过 `$('#manage_price_datagrid').datagrid('getRows')` 获取到了 Datagrid 中的所有行数据,并将它们赋值给了 `price_rows` 数组。然后通过遍历这个数组,找到 `isTag` 属性为真的行,并使用 `$('#manage_price_datagrid').datagrid('deleteRow', deleteIndex)` 方法从 Datagrid 中删除这些行。
至于你的问题,我并不是很清楚你想要表达的意思。可以再提供一些上下文或者具体的问题吗?
var price_rows = $('#manage_price_datagrid').datagrid('getRows'); price_rows.forEach(function(price_row) { if(price_row.isTag != null){ $('#manage_price_datagrid').datagrid('deleteRow', $('#manage_price_datagrid').datagrid('getRowIndex',price_row)); } });为什么只删除了第一天
根据你提供的代码,无法确定为什么只删除了第一行。不过,这段代码的功能是从名为 "manage_price_datagrid" 的 DataGrid 中删除具有 "isTag" 属性的行。如果只删除了第一行,可能有以下原因:
1. 只有第一行具有 "isTag" 属性,其他行没有该属性。
2. 在删除第一行后,DataGrid 的行数发生了变化,导致后面的行无法正确获取索引。
你可以通过使用控制台输出调试语句来检查这些变量和操作,以更好地理解代码的执行过程和问题所在。