SMART datagrid v.1 > Classes > GridBase

Back  Forward

DataLudi.GridBase.setSelection  method

通过style形式,选择index1index2之间的区域。 

如果没有指定style,就会遵循DisplayOptions.selectStyle设置。 如果focustrue,就会根据index1style设置,重新设置聚焦单元格位置。 如果index1CellIndex对象,就会将焦点无条件设置在其位置,如果style为行选择,则会维持聚焦列,而如果为列选择,就会维持聚焦行。 单选等其他情况,则通过最接近index1值的单元格,设置焦点。 

function setSelection (index1: CellIndex|Integer|GridColumn, index2: CellIndex|Integer|GridColumn, style: SelectionStyle, focus: Boolean): SelectionItem;
Returns
SelectionItem
Parameters
index1 - CellIndex|Integer|GridColumn. required.
选中区域的起始位置。
可以通过整数值,只指定行的位置,或通过GridColumn对象,只指定列的位置。v 1.3.8
index2 - CellIndex|Integer|GridColumn. required.
选中区域的结束位置。
可以通过整数值,只指定行的位置,或通过GridColumn对象,只指定列的位置。v 1.3.8
style - SelectionStyle.
如果没有指定,就会遵循DisplayOptions.selectStyle
focus - Boolean.
如果为true,就会根据新添加的选中区域,变更焦点位置。v 1.3.8
Code -1
    $('#select').click(funciton () {
        var idx1 = grdMain.focusedIndex();
        var idx2 = new DataLudi.CellIndex(grdMain.focusedRowIndex() + 10, idx1.column);
        grdMain.setSelection(idx1, idx2, DataLudi.SelectionStyle.BLOCK, true);
    }
Code -2
    $('#select').click(funciton () {
        grdMain.setSelection(3, 11, DataLudi.SelectionStyle.ROWS, true);
    }
See Also
CellIndex
SelectionStyle
DisplayOptions.selectStyle
Examples
选择