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个回答

$('#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值
                }
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问