JSFiddle - React, Tailwind, and code Playground
JavaScript
$("#load-first").click(function () {
loadDatasourceWithId(108);
});
$("#load-second").click(function () {
loadDatasourceWithId(92);
});
var DataSource;
function EmailTypeDropDownEditor(container, options) {
// /console.log(options);
$('<input required data-text-field="EmailTypeName" data-value-field="EmailTypeId" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
autoBind: false,
dataSource: {
type: "json",
transport: {
read: "operations/GetEmailTypes.php"
}
}
});
}
function loadDatasourceWithId(salesRepsId){
var dataSourceOptions = dataSource.options; // find somehow the dataSource options
dataSourceOptions.transport.read.url = "operations/get_emails_sales_reps.php?salesRepsId="+salesRepsId;
dataSourceOptions.transport.update.url = "operations/edit_email.php?salesRepsId="+salesRepsId;
dataSourceOptions.transport.create.url = "operations/add_email.php?salesRepsId="+salesRepsId
datasource.read(); // read again to get new values to your dataSource
}
function initGrid(){
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "",
type: "GET"
},
update: {
url: "",
type: "POST",
complete: function (e) {
$("#email-grid").data("kendoGrid").dataSource.read();
}
},
destroy: {
url: "operations/delete_email.php",
type: "POST",
complete: function (e) {
$("#email-grid").data("kendoGrid").dataSource.read();
}
},
create: {
url: "operations/add_email.php?salesRepsId=" + salesRepsId,
type: "POST",
complete: function (e) {
...