你好,Alice,完整的代码如下:
- var editBookRoomFlexGrid = undefined;
- var editBookRoomView = undefined;
- //var checkId=$("#viewId").val();
- if(typeof addBookRoomFlexGrid!="undefined"){
- addBookRoomFlexGrid.dispose();
- addBookRoomFlexGrid = undefined;
- }
- $("#isEdit").val("true");
- $("#checkId").val(checkId);
- var url=path+"/bookroom/view.do";
- //加载表单数据
- $.ajax({
- type: "POST",
- url: url,
- data: {checkId:checkId},
- dataType:"json",
- success: function(obj){
- obj.bookTime=new Date(obj.bookTime).format("yyyy-MM-dd hh:mm");
- obj.reachDate=new Date(obj.reachDate).format("yyyy-MM-dd");
- obj.reachtime=new Date(obj.reachDate).format("yyyy-MM-dd hh:mm:ss").substring(11,16);
- obj.leaveDate=new Date(obj.leaveDate).format("yyyy-MM-dd");
- obj.confirmDate=new Date(obj.confirmDate).format("yyyy-MM-dd");
- //setForm("skyd",obj);
- setJSONToForm($("#skyd"),obj);
- objArray=obj;
- }
- });
-
- //打开预定弹出
- $(".orderDetailsDiv").fadeIn();
- $(".alertDivBg").fadeIn();
- //加载预定列表数据
- //bookDiaryGrid(checkId);
- //------加载详情页中的bookRoom的FlexGrid----------
-
- //var path=$("#path").val();
- if(checkId!=""){
- var url=path+"/bookroom/retain.do?checkId="+checkId;
- $.ajax({
- type: "POST",
- url: url,
- data: "checkId="+checkId,
- dataType:"json",
- success: function(msg){
- if(msg.success){
- var editIndex = -1;
- var data = msg.obj;
- if(data!=""&&data.length>0){
- var array_book=[];
- /////// FlexGird ///////
- editBookRoomView = new wijmo.collections.CollectionView(data);
- editBookRoomFlexGrid = new wijmo.grid.FlexGrid('#div_bookRoom', {
- autoGenerateColumns: 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", format:'yyyy-MM-dd', width:'*'},
- { header: '离店日期',binding:"leaveDate", format:'yyyy-MM-dd',width:'*'},
- { header: '抵店时间', width:'*'},
- { header: '房价',binding:"roomPrice", width:'*'},
- { header: '抵达数',binding:"reachNum", width:'*'},
- { header: '操作',name: "buttons",width:'*'},
- ],
- itemsSource: editBookRoomView,
- });
-
- editBookRoomFlexGrid.itemFormatter = function(panel, r, c, cell){
- if (panel.cellType == wijmo.grid.CellType.Cell) {
- var col = panel.columns[c],
- html = cell.innerHTML;
- if (r == editIndex) {
- /*switch (col.name) {
- case 'buttons':
- html = '<div>' +
- '&nbsp;&nbsp;' +
- '<button class="btn btn-primary btn-sm" onclick="commitRow(' + r + ')">' +
- '<span class="glyphicon glyphicon-ok"></span> OK' +
- '</button>' +
- '</div>';
- break;
- case 'date':
- break;
- }*/
- } else {
- switch (col.name) {
- case 'buttons':
- cell.style.padding = '3px';
- html = '<div>' +
- '&nbsp;&nbsp;' +
- '<button ">' +
- '留房123' +
- '</button>' +
- '</div>';
- break;
- }
- }
-
- if (html != cell.innerHTML) {
- cell.innerHTML = html;
- cell.style.padding = '3px';
- }
-
- }
- };
- editBookRoomView.trackChanges = true;
- var col = editBookRoomFlexGrid.columns.getColumn('roomtypeId');
- col.dataMap = new wijmo.grid.DataMap(msg.attributes.roomTypeList, 'codeId', 'codeNamec');
- }
- }
- }
- });
-
- }else{
- alert("加载默认列表");
-
- }
-
复制代码 |