$(function () { 'use strict'; BWA.Popup.BudgetPlan2 = BWA.Popup.BudgetPlan2 || {}; BWA.Popup.BudgetPlan2.create = function (viewModel, options) { options = options || {}; var onSelectedBudgets = options.onSelectedBudgets; var popupVisible = ko.observable(false); var budgetDataSource = BemsWebApplication.db.createDataSource('FmsBudget', true, false, true); var selectedYear = ko.observable(); var dataViewModel = new BemsWebApplication.FmsBudgetViewModel(), initialized = false, gridView; // // equipmentFactory = BemsWebApplication.Factory.Equipment, // dataSource = BWA.DataUtil.createDataSource({ dataSourceOptions: equipmentFactory.getDataSourceForDataGrid() }, 'FmsEquipmentEx'); var eq = BWA.DataUtil.constructEqualFilter, and = BWA.DataUtil.andFilter; // 자재 검색시 나타나는 팝업은 공통 및 자신이 포함된 비즈니스 영역만 해당됨 var userInfo = BWA.UserInfo; var dataGridOptions = utils.datagrid.defaultOptions({ pager: { showPageSizeSelector: false, allowedPageSizes: [] }, dxDataSource: budgetDataSource, // 아래들이 동작하지 않음 selectedSourceItem: dataViewModel, handleDataGridRowClick: function () { }, columns: [ { dataField: 'Year', caption: 'Year', alignment: 'center', sortOrder: 'desc' }, ], wordWrapEnabled: true // cellPrepared: BemsWebApplication.Factory.Equipment.cellPrepared }); dataGridOptions.handleDataGridRowClick = function (id, dataGrid, clickRow) { var data = clickRow.data; if (!_.isUndefined(onSelectedBudgets)) { onSelectedBudgets([BWA.DataUtil.convertViewModelToJS(data)]); } popupVisible(false); } var toolbarItems = [ { location: 'before', text: '예산년도 선택' }, { location: 'after', widget: 'button', options: { text: $G('select'), icon: 'save', clickAction: handlePopupButtonSelect } }, //, visible: isMultipleSelect, { location: 'after', widget: 'button', options: { text: $G('close'), icon: 'close', clickAction: handlePopupButtonClose } } // ]; var popupOptions = { width: '400px', height: 'auto', visible: popupVisible, closeOnOutsideClick: true, //showingAction: handlePopupShowing, shownAction: handlePopupShown, animation: window.utils.popup.createAnimation() }; function handlePopupShown() { if (initialized === false) { gridView = $('#budgetDataGridForYear').dxDataGrid('instance'); initialized = true; } gridView.clearSelection(); gridView.refresh(); } function handlePopupButtonSelect() { //dataViewModel = gridView.getSelectedRowsData()[0]; //selectedYear = dataViewModel.Year(); //popupVisible(false); var array = gridView.getSelectedRowsData()[0]; if (!_.isUndefined(onSelectedBudgets)) { onSelectedBudgets(array); } popupVisible(false); } function handlePopupButtonClose() { popupVisible(false); } return { dataModel: dataViewModel, //dataSource: dataSource, selectedYear:selectedYear, popupOptions: popupOptions, toolbarItems: toolbarItems, dataGridOptions: dataGridOptions, popupVisible: popupVisible, onSelectedBudgets : onSelectedBudgets, // hcLee 2015 12 09 show: function () { popupVisible(true); } }; }; });