【问题标题】:Gxt: How to disable the checkbox of CheckBoxSelectionModelGxt:如何禁用 CheckBoxSelectionModel 的复选框
【发布时间】:2016-12-13 19:09:26
【问题描述】:

我们一直在 GXT 的网格中使用 CheckBoxSelectionModel。我们希望某行有一个特别的复选框被选中和禁用,即 CheckBoxSelectionModel 的复选框将被选中并变灰,用户无法选中或取消选中它。

CheckBoxSelectionModel sm = new CheckBoxSelectionModel<ModelData>();
ColumnConfig checkBoxColumn = sm.getColumn();
checkBoxColumn.setStyle("vertical-align: middle;");
checkBoxColumn.setRenderer(new GridCellRenderer<ModelData>()
{
    @Override
    public Object render(ModelData model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<ModelData> store, Grid<ModelData> grid)
    {
        // if the code property of model is 1 then select and disable it
        if (model.get("code").equals(1))
        {
            sm.select((BaseModel) model, true);
            return "<div>&#160;</div>";
        } else { // others case
            return "<div class=\"x-grid3-row-checker\">&#160;</div>";
        }
    }
});
columnConfigs.add(checkBoxColumn);

我们已经从link 建议中尝试了上面的代码,但这会隐藏我们不需要的复选框。

不知道有没有其他更合适的方法来禁用 CheckBoxSelectionModel 的复选框?

感谢任何帮助。

【问题讨论】:

    标签: javascript extjs checkbox gwt gxt


    【解决方案1】:

    CheckBoxSelectionModel sm 具有布尔锁定属性,它接受一个参数。所以在渲染器中设置你想要的值;

    文档: True 锁定选择模型。锁定后,将禁用所有选择更改。 @param locked true 以锁定

    sm.setLocked(true)sm.setLocked(false)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多