Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

jquery - 如何在Slickgrid中获取选定的列(How to get selected columns in slickgrid)

I am using mleibman/SlickGrid and have checkbox (isChecked) column,

(我正在使用mleibman / SlickGrid并具有复选框(isChecked)列,)

var columns = [                
            { id: "tagID", name: "#", field: "tagID", behavior: "select", cssClass: "cell-selection", width: 40, cannotTriggerInsert: true, resizable: false, selectable: false, excludeFromColumnPicker: true },
            { id: "isChecked", name: "isChecked", field: "isChecked", width: 80, minWidth: 20, maxWidth: 80, cssClass: "slick-cell-check", formatter: Slick.Formatters.Checkbox, editor: Slick.Editors.Checkbox, sortable: true },
            { id: "tagName", name: "tagName", field: "tagName", width: 90, minWidth: 120, cssClass: "cell-title", sortable: true },
            { id: "description", name: "description", field: "description", width: 120, minWidth: 120, cssClass: "cell-title", sortable: true }
        ]; 

How to get all selected/checked rows.

(如何获取所有选中/选中的行。)

My Approach:

(我的方法:)

function GetCheckedRows() {
    var checkedRows = [];
    for (var i = 0; i < grid.getDataLength(); i++) {
       if (grid.getDataItem(i).isChecked
            checkedRows.push(grid.getDataItem(i));
    }
    console.log(checkedRows);                
 }

Calling GetCheckedRows never returns first checked row, second checked row comes and deselecting doesn't removes from checkedRows.

(调用GetCheckedRows永远不会返回第一个选中的行,第二个选中的行会出现,并且取消选择不会从checkedRows中删除。)

  ask by Kumar Gaurav translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For a start use 6pac SlickGrid , the MLeibman repo is dead now.

(首先使用6pac SlickGrid ,MLeibman仓库现在已经死了。)

Are you missing a closing ')' in the line

(您是否在行中缺少结尾的')')

if (grid.getDataItem(i).isChecked

or is this just a typo in what you've posted?

(还是这只是您所张贴内容的错字?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...