EasyUI之datagrid的复选框使用

复选框是什么:放置一个复选框列到数据网格(DataGrid),用户将可以选择 选中/取消选中 网格行数据。


如何放置一个复选框:为了添加一个复选框列,只需添加一个列的 checkbox 属性,并设置它为 true。代码如下所示:

    	<table id="tt" title="Checkbox Select" class="easyui-datagrid" style="width:550px;height:250px"
    			url="data/datagrid_data.json"
    			idField="itemid" pagination="true"
    			iconCls="icon-save">
    		<thead>
    			<tr>
    				<th field="ck" checkbox="true"></th>      //在这里就是设置复选框的语句
    				<th field="itemid" width="80">Item ID</th>
    				<th field="productid" width="80">Product ID</th>
    				<th field="listprice" width="80" align="right">List Price</th>
    				<th field="unitcost" width="80" align="right">Unit Cost</th>
    				<th field="attr1" width="100">Attribute</th>
    				<th field="status" width="60" align="center">Status</th>
    			</tr>
    		</thead>
    	</table>

以上代码添加了一个带有 checkbox 属性的列,所以它将成为复选框列。如果 idField 属性已设置,数据网格(DataGrid)的选择集合将在不同的页面保持。

datagrid有两种属性用来操作复选框:

名称 类型 描述 默认值
checkOnSelect boolean 如果设置为 true,当用户点击某一行时,则会选中/取消选中复选框。如果设置为 false 时,只有当用户点击了复选框时,才会选中/取消选中复选框。该属性自版本 1.3 起可用。 true
selectOnCheck boolean 如果设置为 true,点击复选框将会选中该行。如果设置为 false,选中该行将不会选中复选框。
该属性自版本 1.3 起可用。
true  
   
   

猜你喜欢

转载自blog.csdn.net/tritoy/article/details/80966732
今日推荐