你好Alice:
我这里有这么一个需求,就是初始化的时候是没有数据的,但是默认第一行的操作列里要有一个按钮,并且每个按钮的value绑定的是当前行的默认ID,我写的代码没有没有执行成功,按钮没有显示出来,麻烦看下是哪里的问题!
- var viewArray = [];
- for(var i=0;i<msg.attributes.list.length;i++){
- appData.push({
- id:msg.attributes.list[i][id],
- roomtypeId:msg.attributes.list[i][roomtypeId],
- bookNum:msg.attributes.list[i][bookNum],
- saveNum:msg.attributes.list[i][saveNum],
- reachDate:msg.attributes.list[i][reachDate],
- leaveDate:msg.attributes.list[i][leaveDate],
- roomPrice:msg.attributes.list[i][roomPrice],
- reachNum:msg.attributes.list[i][reachNum],
- buttons:""
- });
- }
- //addBookRoomView = new wijmo.collections.CollectionView(msg.attributes.list);
- addBookRoomView = new wijmo.collections.CollectionView(viewArray);
- addBookRoomFlexGrid = new wijmo.grid.FlexGrid('#div_bookRoom', {
- autoGenerateColumns: false,
- allowMerging : wijmo.grid.AllowMerging.All,
- isReadOnly : false,
- selectionMode : wijmo.grid.SelectionMode.Row,
- allowAddNew:true,
- columns: [
- { header: '主键',binding:"id", width:50,isReadOnly:true,visible:false},
- { header: '序号', width:50,isReadOnly:true},
- { header: '房类',binding:"roomtypeId",width:'*' },
- { header: '订房数', binding:"bookNum",width:'*' },
- { header: '留房数', binding:"saveNum",width:'*'},
- { header: '抵店日期',binding:"reachDate", width:'*'},
- { header: '离店日期',binding:"leaveDate", width:'*'},
- { header: '抵店时间', width:'*'},
- { header: '房价',binding:"roomPrice", width:'*'},
- { header: '抵达数',binding:"reachNum", width:'*'},
- { header: '操作', binding:"buttons",width:'*'},
- ],
- itemsSource: addBookRoomView,
- });
-
- addBookRoomView.trackChanges = true;
- addBookRoomFlexGrid.itemFormatter = function(panel, r, c, cell) {
- /*if (r>=0 && panel.columns[c]._hdr == "操作") {
- cell.innerHTML = '<input type="button" name="" value="留房'+1+'">';
- }*/
- if (panel.cellType == wijmo.grid.CellType.Cell) {
- var col = panel.columns[c],
- html = cell.innerHTML;
- if(col.name=='buttons') {
- html = '<div>' +
- '&nbsp;&nbsp;' +
- '<button class="btn btn-primary btn-sm" onclick="commitRow(' + r + ')">' +
- '<span class="glyphicon glyphicon-ok"></span> OK' +
- '</button>' +
- '&nbsp;&nbsp;' +
- '</div>';
- cell.innerHTML = html;
-
- }
- }
- };
-
- var col = addBookRoomFlexGrid.columns.getColumn('roomtypeId');
- col.dataMap = new wijmo.grid.DataMap(msg.attributes.roomTypeList, 'codeId', 'codeNamec');
-
-
复制代码 |