Nuvolar_Scanner_Android.StorageOutRowsEdit = function (params) {

    var viewModel = {
        viewShown: function (e) {
            $("#gridContainer").dxDataGrid({
                dataSource: dataSourcePDARows,
                allowColumnReordering: true,
                allowColumnResizing: true,
                showColumnLines: true,
                showRowLines: true,
                rowAlternationEnabled: true,
                columnAutoWidth: true,
                height: 450,
                columnChooser: {
                    enabled: false
                },
                scrolling: {
                    mode: 'infinite'
                },
                columnFixing: {
                    enabled: true
                },
                selection: {
                    mode: 'multiple',
                    allowSelectAll: false
                },
                columns: [{
                    dataField: "Oid",
                    visible: false,
                    key: true
                },
                          { dataField: "QTT", caption: 'M.' },
                          { dataField: "ShortName", caption: 'Megnevezés' },
                          { dataField: "ProductNumber", caption: 'Cikkszám' },
                          {
                              dataField: "RowIndex", caption: 'S.',
                              allowSorting: true,
                              sortIndex: 1,
                              sortOrder: 'desc'

                          }
                ]
            });
            
            SimpleQuery.UserName = username();
            SimpleQuery.Password = password();
            SimpleQuery.Database = database();
            SimpleQuery.Query = 'DX_GetStorageOutRows_dxDataGrid;' + params.id;
            JSON_Text = JSON.stringify(SimpleQuery, null);
            $.getJSON(URL(), 'id=' + JSON_Text, function (results) {
                dataSourcePDARows = JSON.parse(JSON.parse(results).Result);
                $("#gridContainer").dxDataGrid({ dataSource: dataSourcePDARows })
            }
           ).done(function () {
               //alert("second success");
           }).fail(function (jqXHR, textStatus, errorThrown) {
               DevExpress.ui.notify("Kapcsolati hiba, próbálja meg újra!", "error", 2000);
           });

        },
        onEnterKeyBarcode: function (e) {
            SimpleQuery.UserName = username();
            SimpleQuery.Password = password();
            SimpleQuery.Database = database();
            SimpleQuery.Query = 'DX_InsertStorageOutRows_dxDataGrid;' + Barcode() + ';' + params.id + ';' + QTT();
            JSON_Text = JSON.stringify(SimpleQuery, null);

            $.getJSON(URL(), 'id=' + JSON_Text, function (results) {
                Barcode("");
                dataSourcePDARows = JSON.parse(JSON.parse(results).Result);
                $("#gridContainer").dxDataGrid({ dataSource: dataSourcePDARows })
                $("#BarcodeText").dxTextBox("instance").focus();
            }
            ).done(function () {
            }).fail(function (jqXHR, textStatus, errorThrown) {
                DevExpress.ui.notify("Kapcsolati hiba, próbálja meg újra!", "error", 2000);
            });
        },
        removerows: function (e) {
            var dataGrid = $('#gridContainer').dxDataGrid('instance');
            var items = dataGrid.getSelectedRowsData();
            for (i = 0; i < items.length; i++) {
                SimpleQuery.UserName = username();
                SimpleQuery.Password = password();
                SimpleQuery.Database = database();
                SimpleQuery.Query = 'DX_DeleteStorageOutRows_dxDataGrid;' + items[i].Oid;
                JSON_Text = JSON.stringify(SimpleQuery, null);

                $.getJSON(URL(), 'id=' + JSON_Text, function (results) {
                }
                ).done(function () {
                    //alert("second success");
                }).fail(function (jqXHR, textStatus, errorThrown) {
                    DevExpress.ui.notify("Kapcsolati hiba, próbálja meg újra!", "error", 2000);
                });
            };
            SimpleQuery.UserName = username();
            SimpleQuery.Password = password();
            SimpleQuery.Database = database();
            SimpleQuery.Query = 'DX_GetStorageOutRows_dxDataGrid;' + params.id;
            JSON_Text = JSON.stringify(SimpleQuery, null);
            $.getJSON(URL(), 'id=' + JSON_Text, function (results) {
                dataSourcePDARows = JSON.parse(JSON.parse(results).Result);
                $("#gridContainer").dxDataGrid({ dataSource: dataSourcePDARows })
            }
           ).done(function () {
               //alert("second success");
           }).fail(function (jqXHR, textStatus, errorThrown) {
               DevExpress.ui.notify("Kapcsolati hiba, próbálja meg újra!", "error", 2000);
           });
        }
    };

    return viewModel;
};