jiaoye6789
jiaoye6789
2016-07-25 09:04
采纳率: 70.4%
浏览 3.1k
已采纳

Easyui加载datagrid的,combobox的首选项的值作为queryParams传到后台

 <script type="text/javascript">
 $(function () {
            $('#parkArea').combobox({
                url: '/VenueVehicle/LoadParkingAreas',
                valueField: 'PARKING_AREA_ID',
                textField: 'NAME',
                panelHeight: 'auto',
                editable: false,
                onLoadSuccess: function () {
                    var data = $('#parkArea').combobox('getData');
                    if (data.length > 0) {
                        $('#parkArea').combobox('select', data[0].PARKING_AREA_ID);
                    }
                }
            });
            $('#dgVenueVehicle').datagrid({
                fitColumns: true,
                url: '/VenueVehicle/LoadVenueVehicle',
                idField: 'ENTERING_ID',
                toolbar: '#tb',
                autoSizeColumn: true,
                nowrap: true,
                resizable: true,
                pagination: true,
                singleSelect: true,
                rownumbers: true,
                queryParams: { parkArea: $('#parkArea').combobox('getValue') },
                pageSize: 10,
                pageNumber: 1,
                pageList: [10, 15, 20],
                columns: [[
                    { field: 'VEHICLE_LICENSE_PLATE_NO', title: '车牌号码', width: 100 },
                     { field: 'VEHICLE_TYPE_NAME', title: '车辆类型', width: 100 },
                     { field: 'ENTER_TIME', title: '进入时间', width: 100 },
                     { field: 'PARK_AREA_NAME', title: '停车区域', width: 100 }
                ]],
                onClickRow: function (index, row) {
                    if (row.PIC_URL == null) {
                        $('#imgEntering').attr("src", "");
                    }
                    else {
                        var enteringUrl = row.PIC_URL;
                        var enteringName = enteringUrl.match(/[^\/]*$/)[0];
                        $('#imgEntering').attr("src", enteringUrl.replace(enteringName, $URL.encode(enteringName)));
                    }
                },
                onLoadSuccess: function (data) {
                    var dd = $.parseJSON(data)
                    alert(data.rows[0].VEHICLE_LICENSE_PLATE_NO);
                }
            });
        })
 </script>

方法好像是加载完combobox后,并没有加载onLoadSuccess,就加载了datagrid

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • showbo
    已采纳

    $('#dgVenueVehicle').datagrid({.....放到下面标注的地方,因为ajax是异步加载,执行了这句还没执行onLoadSuccess回调,当然获取不到值

                 $('#parkArea').combobox({
                    url: '/VenueVehicle/LoadParkingAreas',
                    valueField: 'PARKING_AREA_ID',
                    textField: 'NAME',
                    panelHeight: 'auto',
                    editable: false,
                    onLoadSuccess: function () {
                        var data = $('#parkArea').combobox('getData');
                        if (data.length > 0) {
                            $('#parkArea').combobox('select', data[0].PARKING_AREA_ID);
                        }
                                            /////////.............放这里才能得到实际的combobox值
                    }
    
    点赞 评论

相关推荐