我想合并/连接两列的内容并将它们显示在一列中。
我希望它会像responseSchema中的[“column 1”+“Column2”]一样简单。所以从下面的代码中,我想做一些像[“item-name”+“condition”,“color”,“keep”]这样的事情。 这是我当前数据表代码的相关部分......
var myColumnDefs = [
{key:"item-name", sortable:true, resizeable:true, width:100},
{key:"condition", sortable:true, resizeable:true},
{key:"color", sortable:true, resizeable:true},
{key:"keep", sortable:true, resizeable:true},
];
var myDataSource = new YAHOO.util.DataSource("http://192.168.2.5:3000/items.xml");
myDataSource.responseType = YAHOO.util.DataSource.TYPE_XML;
myDataSource.responseSchema = {
resultNode: "item",
fields: ["item-name", "condition", "color", "keep"]
};
var myDataTable = new YAHOO.widget.DataTable("dt-container",
myColumnDefs, myDataSource);
答案 0 :(得分:2)
尝试更改
{key:"item-name", sortable:true, resizeable:true, width:100},
行到
{key:"item-name", sortable:true, resizeable:true, width:100,
formatter: function (el, oRecord, oColumn, oData) {
var condition = oRecord.getData('condition');
el.innerHTML += ' ' + condition;
}
},
然后删除
{key:"condition", sortable:true, resizeable:true},
线。