01.
function WarehouseGridOperations() {
02.
var grid = new BaseGrid('grdWarehouse_OnWarehouseRelation');
03.
grid._batch = true;
04.
grid._autoBind = false;
05.
grid._dataSourceAutoSync = false;
06.
grid._toolbar = ['create'/*, 'save', 'cancel'*/];
07.
grid._editable = {
08.
mode: "inline",
09.
create: true,
10.
update: true,
11.
destroy: true,
12.
edit: false,
13.
};
14.
grid._autoBind = true;
15.
16.
grid._schemaMethod = {
17.
model: {
18.
id: 'Id',
19.
fields: {
20.
Warehouse: { defaultValue: { Id: '', WarehouseName: '' } },
21.
ProcessType: { defaultValue: { Value: '', Text: '' } },
22.
}
23.
}
24.
};
25.
grid._columns.push(grid.GridColumn('Id', null, '200px', null, null, null, null, null, null, null, true));
26.
grid._columns.push(grid.GridColumn('Warehouse', Field_RelatedWarehouse, '200px', null, "#=Warehouse.WarehouseName#", null, null, null, null, null, null, null, null, null, RelatedWarehouseEditor));
27.
grid._columns.push(grid.GridColumn('ProcessType',Field_ProcessType, '200px', null, "#=ProcessType.Text#", null, null, null, null, null, null, null, null, null, ProcessTypeEditor));
28.
grid._columns.push(grid.GridColumn(null, ' ', '200px', { style: 'text-align:right' }, null, null, null, null, null, null, null, null, null, ['edit', 'destroy']));
29.
30.
31.
grid._updateMethod = function (options) {
32.
33.
};
34.
35.
grid._editMethod = function (options) {
36.
37.
};
38.
39.
grid._createMethod = function (options) {
40.
41.
for (var a = 0; a < options.data.models.length; a++) {
42.
for (var i = a+1 ; i < options.data.models.length; i++) {
43.
if (options.data.models[i].ProcessType.Value == options.data.models[a].ProcessType.Value && options.data.models[i].Warehouse.Id == options.data.models[a].Warehouse.Id) {
44.
toastr.error(Message_DefinedRecord);
45.
return null;
46.
}
47.
}
48.
}
49.
KendoData('grdWarehouse_OnWarehouseRelation').refresh();
50.
};
51.
52.
$(".k-grid-update").on("click", function (e) {
53.
});
54.
grid._readMethod = function (e) {
55.
};
56.
grid._cancelMethod = function (e) {
57.
KendoData('grdWarehouse_OnWarehouseRelation').refresh();
58.
};
59.
grid._dataBoundMethod = function (e) {
60.
e.sender.items().each(function () {
61.
62.
var dataItem = e.sender.dataItem(this);
63.
kendo.bind(this, dataItem);
64.
});
65.
};
66.
grid.GetGrid();
67.
};
01.
function
ProcessTypeEditor(container, options) {
02.
03.
var
processType = [
04.
{
"Text"
:
"Transfer"
,
'Value'
: 1 },
05.
{
"Text"
:
"Talep"
,
'Value'
: 2 }
06.
];
07.
$(
'<input name="'
+ options.field +
'"/>'
)
08.
.appendTo(container)
09.
.kendoComboBox({
10.
autoBind:
false
,
11.
dataTextField:
"Text"
,
12.
dataValueField:
"Value"
,
13.
dataSource: { data: processType },
14.
});
15.
};
16.
function
RelatedWarehouseEditor(container, options) {
17.
18.
GetWarehouseListByFacilityId();
19.
20.
$(
'<input name="'
+ options.field +
'"/>'
)
21.
.appendTo(container)
22.
.kendoDropDownList({
23.
autoBind:
true
,
24.
dataTextField:
"WarehouseName"
,
25.
dataValueField:
"Id"
,
26.
dataSource: { data: warehouseList_OnContactInfo },
27.
});
28.
};