Skip to content

Instantly share code, notes, and snippets.

@NickersF
Created October 10, 2022 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickersF/46c2384c5e889ed471cf30909744f652 to your computer and use it in GitHub Desktop.
Save NickersF/46c2384c5e889ed471cf30909744f652 to your computer and use it in GitHub Desktop.
open config method
openConfig(config: string, hidewindow: boolean = false) {;
//config will be sent here from the dropdown or default to default;
if ($('#OnScreenConfig').val() != "") config = $('#OnScreenConfig').val();
else config = $('#OnScreenConfig').data('kendoDropDownList').text();
var self = this;
// Setup ListView DataSource object
self.gridConfigManagerDataSource = new kendo.data.DataSource({
transport: {
create: {
url: "/GridConfigView/SaveGridConfig",
type: "POST",
dataType: "json",
data: {
page: GridConfigController._page,
configName: $("#GridConfigName_Input").val(),
configData: GridConfigController.configItems
}
},
read: {
url: "/GridConfigView/GetConfigListViewItems",
type: "GET",
dataType: "json",
data: {
page: GridConfigController._page
}
}
},
schema: {
model: {
id: "GridConfiguration_Key",
fields: {
GridConfiguration_Key: { type: "number", editable: false },
PageName_Key: { type: "number" },
Name: { type: "string" },
Configuration: { type: "string" },
CreatedDate: { type: "date", nullable: true },
CreatedByUser_Key: { type: "number", nullable: true },
UpdatedDate: { type: "date", nullable: true },
UpdatedByUser_Key: { type: "number", nullable: true },
Tenant_Key: { type: "number" }
}
}
},
requestEnd: function (e) {
let type = e.type;
switch (type) {
case "create":
console.log(e);
console.log(type);
break;
case "read":
console.log(type);
break;
case "update":
console.log(type);
//gridConfigControllerInstance.gridConfigManagerListViewInstance.dataSource.read();
//$("#ConfigViewConfigs").data("kendoDropDownList").dataSource.read();
break;
case "destroy":
console.log(type);
break;
default:
console.log("No response type available.");
}
}
});
var waiting = new Promise<void>((resolve, reject) => {
if (hidewindow) $('#ConfigContainer').css('display', 'none');
else if ($('#ConfigContainer').css('display') !== 'block') $('#ConfigContainer').css('display', 'block');
OpenWindow('configWindow').then(() => {
self.layoutEvents(); // Binds expander and modal events
// Create the ListView component
$("#GridConfigManager_ListView").kendoListView({
template: kendo.template($("#GridConfigManagerTemplate").html()),
editTemplate: kendo.template($("#GridConfigManagerEditTemplate").html()),
dataSource: self.gridConfigManagerDataSource,
selectable: true
});
// Store an instance of the ListView component for access
self.gridConfigManagerListViewInstance = $("#GridConfigManager_ListView").data("kendoListView");
// Bind ListView UI events
self.selectGridConfigListViewItem();
self.addGridConfigListViewItem();
self.bindGridConfigListViewItemViewEvents();
//Load Config list to Config Window
$("#ConfigViewConfigs").kendoDropDownList(kendoDropDownListDefaultOptions({
autoBind: false,
filter: "contains",
dataSource: {
transport: {
read: {
url: "/GridConfigView/GetConfigList",
data: { page: GridConfigController._page }
},
prefix: ""
},
schema: { errors: "Errors" }
},
change: (e) => self.loadConfig(e, config)
}));
GridConfigController.createConfigButtonEvents(config);
$("#GridConfigGrid").data('kendoGrid').dataSource.read({ curModel: GridConfigController._page, lookupConfig: config }).done(() => {
$('#ConfigViewConfigs').data('kendoDropDownList').value(config);
$('#ConfigViewConfigs').data('kendoDropDownList').text(config);
self.rebuildConfigList();
//self.buildConfigDisplayGrid();
resolve();
});
});
});
return waiting;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment