var gridManager = null, refreshFlag = false;
$(document).ready(function () {
        initUI();
        initGrid();
    }
);

function initUI() {
    UICtrl.initDefaultLayout();
}

function initGrid() {
    var toolbarOptions = UICtrl.getDefaultToolbarOptions({

    });

    gridManager = UICtrl.grid('#anlngrid', {
            columns: [
                {
                    display: "工厂", name: "BUKRS", width: "80", align: "left", type: "string",
                },
                {
                    display: "资产编号", name: "ANLN1", width: "200", align: "left", type: "string",
                },
                {
                    display: "资产描述", name: "TXT50", width: "300", align: "left", type: "string",
                },
            ],
            dataAction: 'server',
            url: web_app.name + '/sapPurchase/queryAnlanFromSap.ajax?',
            parms: {werks: $("#werks").val()},
            toolbar: toolbarOptions,
            width: '99.8%',
            height: 500,
            pageSize: 20,
            heightDiff: -4,
            sortName: 'num',
            sortOrder: 'asc',
            checkbox: true,
            usePager: false,
            rownumbers: true,
            enabledEdit: true,
            fixedCellHeight: true,
            selectRowButtonOnly: true,
            enableObjectBag: true
        }
    );
    UICtrl.setSearchAreaToggle(gridManager);
}

function reloadGrid() {
    gridManager.loadData();
}

function query(obj) {
    var param = $(obj).formToJSON();
    UICtrl.gridSearch(gridManager, param);
}

function resetForm(obj) {
    $(obj).formClean();
}

