简体   繁体   English

Kendo-ui网格在同一列中具有差异字段类型

[英]Kendo-ui grid with differents field type in the same column

I´d be very grateful if someone could help me out with this issue. 如果有人可以帮助我解决这个问题,我将不胜感激。

I´ve a kendo grid in my web app. 我的网络应用程序中有一个剑道网格。 This kendo grid is poblated with a set of questions and answer. 这个剑道网格带有一系列问题和答案。 I mean has two columns, the first one is the question and the second column is for the answer. 我的意思是有两列,第一列是问题,第二列是答案。

The question column is type text but the answer column may be of three types (boolean, selectablelist or text). 问题列是文本类型,但答案列可以是三种类型(布尔,可选择列表或文本)。

Throught creating a custom editor I achieved to have the right field type when you press in the cell. 通过创建自定义编辑器,我实现了当您按单元格时具有正确的字段类型。

I attach a image to explain: snapshot1 The problem is that when the cell lost the focus the custom editor template is not visible anymore so the grid looks like: snapshot2 我附上一张图片来说明: snapshot1问题是当单元格失去焦点时,自定义编辑器模板不再可见,因此网格如下所示: snapshot2

I´d like to keep the checkbox template when I´m editing the cell and also when I´m not editing it. 在编辑单元格以及不编辑单元格时,我想保留复选框模板。

I´ve tried to create a custom template for the editor and a custom template for the cell (while I´m not editing it) but this solution creates two different DOM object, so when I click in the cell I´m clicking in the template, not in the grid, so the grid doesn´t recognize when i´m doing changes. 我尝试为编辑器创建一个自定义模板,为该单元格创建一个自定义模板(虽然我没有对其进行编辑),但是此解决方案创建了两个不同的DOM对象,因此当我单击该单元格时,我单击了模板,而不是在网格中,因此我进行更改时网格无法识别。

Thanks in advance! 提前致谢!

A way to solve your checkbox issue is to use a custom template. 解决复选框问题的一种方法是使用自定义模板。 Take a look at the following DOJO 看看下面的DOJO

Note the function createCheckbox() . 注意函数createCheckbox() It uses model binding to show the correct value and disables the checkbox so a user can only change its value in the edit mode. 它使用模型绑定显示正确的值并禁用该复选框,因此用户只能在编辑模式下更改其值。

function createCheckbox(fieldName) {
    return '<input style="cursor:default;" type="checkbox" data-bind="checked: #=' 
      + fieldName + '#"  #= ' + fieldName 
      + ' ? \'checked="checked"\' : "" # disabled="disabled" />';
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM