Kendo ui 传递剑道网格模板函数中的detailrow引用
嗨,有没有办法使用剑道网格模板列将detailRow引用传递给函数 这是我的线索Kendo ui 传递剑道网格模板函数中的detailrow引用,kendo-ui,kendo-grid,jquery-templates,Kendo Ui,Kendo Grid,Jquery Templates,嗨,有没有办法使用剑道网格模板列将detailRow引用传递给函数 这是我的线索 function detailInit(e) { detailRow = e.detailRow; detailRow.find("#mygrid").kendoGrid({ dataSource: { data: empModel, },
function detailInit(e) {
detailRow = e.detailRow;
detailRow.find("#mygrid").kendoGrid({
dataSource: {
data: empModel,
},
columns: [
{
field: "empId",
title: "Emp ID",
template: '<a href="\\#" onclick="showEmpDetails(\'#= detailRow #\')"> }
]
});
});
函数detailInit(e){
detailRow=e.detailRow;
detailRow.find(“#mygrid”).kendoGrid({
数据源:{
数据:EMP模型,
},
栏目:[
{
字段:“empId”,
标题:“Emp ID”,
模板:'}
]
});
});
尝试将在detailInit
中检索到的每个detailRow放入全局数组,然后将此索引传递给click方法(或某种键-可能是dictionary,rows有uid),然后根据传入的id使该方法从数组/集合中读取行详细信息。(理想情况下,通过uid直接从数据源读取行详细信息,无需复制数据。)请参考以下代码作为伪代码,我没有机会运行它
var rows = new Array();
$('.clickable').click(function () {
// get the id for your detail
var detailId = this.attr('detailId');
// pass it further
showEmpDetails(detailId);
});
function detailInit(e) {
detailRow = e.detailRow;
// add roe to your (cache) collection
rows[rows.legth] = detailRow ;
detailRow.find("#mygrid").kendoGrid({
dataSource: {data: empModel},
columns: [
{
field: "empId",
title: "Emp ID",
// add attribute onto your a tag
template: '<a href="\\#" detailId = "#= rows.legth #" class="clickable">'
}
]
});
});
function showEmpDetails(id) {
// read from your collection and do what you need
console.log(rows[id]);
}
var rows=new Array();
$('.clickable')。单击(函数(){
//获取详细信息的id
var detailId=this.attr('detailId');
//再传下去
showEmpDetails(detailId);
});
函数detailInit(e){
detailRow=e.detailRow;
//将roe添加到(缓存)集合中
行[rows.legth]=detailRow;
detailRow.find(“#mygrid”).kendoGrid({
数据源:{data:empModel},
栏目:[
{
字段:“empId”,
标题:“Emp ID”,
//将属性添加到a标记上
模板:“”
}
]
});
});
函数showEmpDetails(id){
//阅读你的收藏,做你需要的
console.log(行[id]);
}
我认为这很好。但我们能在不存储在全局数组中的情况下实现这一点吗?有什么解决方案吗?有,不是使用全局数组,而是通过uid直接引用datasource.data()。这个解决方案的问题是,您必须遍历data()来查找行,这可能需要相当长的时间,因为uid是一个guid,而不是html标记公开的最佳选择。我至少会像上面所示查找索引和uid,例如,您仍然会将实际数据存储在数据源中,但通过uid字典和数组索引/键获取它们。