Jquery 剑道UI网格:添加包含影响模板的变量的行
我的问题与我的网格更新有关。以下是我当前的网格生成计划:Jquery 剑道UI网格:添加包含影响模板的变量的行,jquery,grid,kendo-ui,row,kendo-grid,Jquery,Grid,Kendo Ui,Row,Kendo Grid,我的问题与我的网格更新有关。以下是我当前的网格生成计划: leTle[0] = {index : 1, tle : tleId, nom : nomChamp, estar : "", fige : tleFixe, position : positionParam, longueur : longueurParam}; var fige; if (tleFixe == "true") fige = true; else
leTle[0] = {index : 1, tle : tleId, nom : nomChamp, estar : "", fige : tleFixe, position : positionParam, longueur : longueurParam};
var fige;
if (tleFixe == "true")
fige = true;
else
fige = false;
$("#" + theId).kendoGrid({
columns:[{
field: "index",
title: "Index",
template: "<span style='font-size: 12px;' title='#= index #'>#= index # </span>",
width: 40
},{
field: "tle",
title: "TLE Id",
template: "<span style='font-size: 12px;' title='#= tle #'>#= tle # </span>",
width: 100
},{
field: "nom",
title: "Intitulé",
template: "<span style='font-size: 12px;' title='#= nom #'>#= nom # </span>"
},{
field : "position",
title : "Position",
width : 70,
attributes : {
"class" : fige ? " " : "fondRougePale"
}
},{
field : "longueur",
title : "Longueur",
width : 70,
attributes : {
"class" : fige ? " " : "fondRougePale"
}
},{
field :"estar",
title :"Estar",
template: "<span class='eStar'><input class='inputeStar' disabled type='text' /> </span>",
width : 250
},{
command: {
name : "destroy",
template: "<a class=\"btn btn-warning btn-mini k-grid-delete\">"
+ "<i class=\"icon-minus-sign icon-white\"></i></a>"
},
title: " ",
width: 40
}
],
dataSource: {
data: leTle,
schema: {
model: {
fields: {
tle: {editable: false},
nom: {editable: false},
estar: {editable: false},
longueur: {editable: fige},
position: {editable: fige}
}
}
}
},
editable: {
mode: "incell",
confirmation: false
},
scrollable : false
});
所以,我的变量是好的,但是新行不是
你知道这种情况下的解决方案吗
非常感谢。这可能不是你的答案,但可能会帮助你实现目标。每次网格的数据源更改时,都会调用formatMe函数,其返回值将显示在网格的单元格中 函数formatMedata{ 返回数据+bla bla; } var grid=$grid.kendoGrid{ 数据源:{ 数据:createRandomData50 }, 栏目:[ {字段:YourFieldName,模板:=formatMedata}] }.datakendoGrid;
最后,我找到了解决这个问题的替代方案 变量fige是在选择单元格时允许编辑的变量。 我宁愿自己解决问题,而不是使用KendoUi 当我构建position和longueur列时:
{
field : "position",
title : "Position",
width : 70,
template : "<span class='position#= index #' ><input style='width:70px' type='text' value='#= position#' #= readOnly(fige) # /></span>"
},{
field : "longueur",
title : "Longueur",
width : 70,
template : "<span class='longueur#= index #'><input style='width:70px' type='text' value='#= longueur#' #= readOnly(fige) # /></span>"
}
由于这个函数,我动态地获得了可编辑或不可编辑的单元格。也许它不如KendoUI默认解决方案好,但我认为由于KendoUI,这个特定功能不可能实现。谢谢,我现在试试你的建议。我不认为应该在=.内部使用函数。所以,当我像您建议的那样在列字段中添加一个类时,这是可以的。但是,当我想使用相同的过程更正schema.model.fields.editable时,这并不好。我想我将直接使用data role=editable进行操作……对不起,我现在太累了,写了10个小时的代码。我认为您应该使用它并将其绑定到网格,然后每次编辑或从数据源中添加或删除它时,都应该自动更新网格,并且自动调用=formatMedata。我不确定是否理解数据源对象的兴趣。我想我已经理解了你所描述的解决方案。实际上,我已经创建了一个网格,它在一个列上有不同的类,这取决于行和返回的=formatMedata。对于模板来说,这是很好的。之后,当我想选择单元格是否可编辑时,相同的机器不工作。我希望我有一个明确的答案,否则我回答我目前的代码。再次感谢。
{
field : "position",
title : "Position",
width : 70,
template : "<span class='position#= index #' ><input style='width:70px' type='text' value='#= position#' #= readOnly(fige) # /></span>"
},{
field : "longueur",
title : "Longueur",
width : 70,
template : "<span class='longueur#= index #'><input style='width:70px' type='text' value='#= longueur#' #= readOnly(fige) # /></span>"
}
function readOnly(fige)
{
if (fige == "true")
return "readonly";
else
return "";
}