开发者

YUI Datatable - merging multiple columns into one column

I'd like to merge/concatenate the contents of two columns and display them in one column.

I was hoping it would be as easy as ["column 1" + "Column2"] inside the responseSchema. So from my code below, I want to do something like ["item-name" + "condition", "color", "keep"]. Here's the relevant part of my current datatable code...

            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);


Try changing the

      {key:"item-name", sortable:true, resizeable:true, width:100},

line to

      {key:"item-name", sortable:true, resizeable:true, width:100, 
        formatter: function (el, oRecord, oColumn, oData) {
          var condition = oRecord.getData('condition');
          el.innerHTML += ' ' + condition;
        }
      },

then removing the

     {key:"condition", sortable:true, resizeable:true},

line.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜