0

I have a gridx/Grid (This is advanced and lighter that dojo DataGrid and Enhanced Grid). I use two layouts for this. One for enabled state and the other for disabled state. Based upon the conditions, respective layout will be used, when the page loads.

The checkbox for every row(the one added on left mist used for row selection), is not part of layout. They are added dynamically by the widget code, based on the number of rows in data returned by the ajax call.

So, we need to disable it manually. But, how do we do that?

4

1 回答 1

0

我想出了如何手动禁用行选择器复选框。我们需要使用 grid.select.row.setSelected() 方法,其中 grid 是 Grid 小部件。

grid.select.row.setSelected(ROWID,BOOLEAN);

第一个 arg 是强制性的,它是该行的 idProperty 的值。第二个 arg 是一个布尔值,使其可选择(“true”)或不可选择(“false”)。如果我们不传递第二个参数,则默认采用 false。

grid.select.row.setSelected("1");=> 将禁用 id="1" 行的行选择器 chkbox

要再次启用它,

grid.select.row.setSelected("1",true);

到目前为止,还没有禁用所有功能的功能。对于这种情况,我们需要一一遍历所有行。header 中的复选框选择器,用于同时选择所有行,它不是其中的一部分,因为它没有 id。我们需要手动禁用它。标题复选框最初加载而不依赖于数据,因此它可以按如下方式进行:-

query(".gridxRowHeaderHeaderCell").style("visibility","hidden");

与此相关的另一个 hack:- 如果 grid.select.row.enable 设置为 false,用户无法选择复选框,但外观不会看起来像已禁用。它看起来很正常,但用户无法选择任何行。

grid.select.row.enable = false;

如果我们想撤销它并使所有行都可选择,只需将其重置为 true。

于 2014-04-11T07:34:20.800 回答