如何制作'type'colDefn的属性在ui网格中更通用
How to make 'type' property of colDefn more generic in ui-grid
我是UI网格的新手,我想显示两列,作为名称和值。如果我双击值列中的单元格,它可以编辑,即它的类型=文本。如何使单元格键入复选框、数字或日期。此colDefn类型应该从数据集中获取值。
代码如下
$scope.gridOptions.data = [{
"index": 0,
"type": "Text",
"id": "name",
"title": "Name",
"value": "Some Name",
},
{
"index": 1,
"type": "date",
"id": "dob",
"title": "DOB",
"value": "1989-02-21T23:02:31+06:00",
},
{
"index": 2,
"type": "number",
"id": "age",
"title": "Age",
"value": 30,
}];
$scope.gridOptions.columnDefs = [
{ field: 'title', displayName: 'Name', enableCellEdit: false, width: '30%'},
{ field: 'value', displayName: 'Value', width: '50%'}]
我知道要使列特定于单个类型。但是如何使单列包含所有类型的字段,如type="number"或"date"或"boolean(即用于复选框)"。
请提出你的建议。
您可以使用自定义模板,例如:
<div><div ng-if="!row.entity.typeCol || row.entity.typeCol === 'text' || row.entity.typeCol === 'date' || row.entity.typeCol === 'boolean'" >
<form
name="inputForm">
<input
type="INPUT_TYPE"
ng-class="'colt' + col.uid"
ui-grid-editor
ng-model="MODEL_COL_FIELD" />
</form>
</div>
<div ng-if="row.entity.typeCol === 'dropdown'">
<form
name="inputForm">
<select
ng-class="'colt' + col.uid"
ui-grid-edit-dropdown
ng-model="MODEL_COL_FIELD"
ng-options="field[editDropdownIdLabel] as field[editDropdownValueLabel] CUSTOM_FILTERS for field in editDropdownOptionsArray">
</select>
</form>
</div>
<div ng-if="row.entity.typeCol === 'file'">
<form
name="inputForm">
<input
ng-class="'colt' + col.uid"
ui-grid-edit-file-chooser
type="file"
id="files"
name="files[]"
ng-model="MODEL_COL_FIELD"/>
</form>
</div>
</div>
是其类型根据字段CCD_ 1而变化的可编辑单元格的基本示例。
我只是复制并粘贴了ui-grid.edit中的基本模板,并在每个模板周围加了一个ng if。
我还没有测试过,但这是唯一的路,IMHO。
相关文章:
- 我可以更改剑道UI网格吗's的外键值
- 如何在Angular UI网格中选择下一行
- 使用导航属性创建Kendo UI网格模型的问题
- ui网格将单元格显示为选择标记
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- 使用按钮的Angular UI网格过滤器
- ui网格:在自定义表头模板中触发排序
- 在有角度的ui网格中设置动态列的问题
- angularjs中的ng网格和ui网格有什么区别
- 在编辑内联模式下禁用Kendo Ui网格按钮
- Angular UI-GRID未在页面上显示网格
- 在angularjs UI网格列中选择下拉菜单不适用于外部editcellTemplate
- 将模型从Kendo Mvc UI网格传递到javascript函数
- 如何在可扩展ui网格中绑定子网格事件
- Typescript Kendo UI网格列类型错误
- ui网格如何在单击行时选中复选框
- Kendo UI网格:数据源刷新后,我丢失了分页
- Kendo UI网格复选框列字段未定义
- 无法将行保存在Angular UI网格中的可展开行中
- Angular UI网格:如何通过第一个UI网格中的按钮使第二个UI网格可见