function onPopupOpen(args) {
if (args.type === 'Editor') {
// Create required custom elements in initial time
if (!args.element.querySelector('.custom-field-row')) {
var row = new ej.base.createElement('div', { className: 'custom-field-row' });
var formElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
var container = new ej.base.createElement('div', { className: 'custom-field-container' });
var inputEle = new ej.base.createElement('input', {
className: 'e-field', id: 'state', attrs: { name: 'State' }
});
container.appendChild(inputEle);
row.appendChild(container);
var drowDownList = new ej.dropdowns.DropDownList({
dataSource: [
{ StateName: "New York", CountryId: "1", StateId: "101" },
{ StateName: "Queensland", CountryId: "2", StateId: "104" },
{ StateName: "Tasmania ", CountryId: "2", StateId: "105" },
{ StateName: "Victoria", CountryId: "2", StateId: "106" },
{ StateName: "Virginia ", CountryId: "1", StateId: "102" },
{ StateName: "Washington", CountryId: "1", StateId: "103" }
],
change: function () {
var cityObj = args.element.querySelector('#city').ej2_instances[0];
var stateObj = args.element.querySelector('#state').ej2_instances[0];
// enable the city DropDownList
cityObj.enabled = true;
// Query the data source based on state DropDownList selected value
var tempQuery1 = new ej.data.Query().where('StateId', 'equal', stateObj.value);
// set the framed query based on selected value in city DropDownList.
cityObj.query = tempQuery1;
//clear the existing selection
cityObj.text = null;
// bind the property change to city DropDownList
cityObj.dataBind();
},
fields: { value: 'StateId', text: 'StateName' },
value: args.EventType,
floatLabelType: 'Always', placeholder: 'State'
});
drowDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'State');
}
if (!args.element.querySelector('.custom-field-row1')) {
var row = new ej.base.createElement('div', { className: 'custom-field-row1' });
var formElement = args.element.querySelector('.e-schedule-form');
formElement.firstChild.insertBefore(row, args.element.querySelector('.e-title-location-row'));
var container = new ej.base.createElement('div', { className: 'custom-field-container' });
var inputEle = new ej.base.createElement('input', {
className: 'e-field', id: 'city', attrs: { name: 'City' }
});
container.appendChild(inputEle);
row.appendChild(container);
var drowDownList = new ej.dropdowns.DropDownList({
dataSource: [
{ CityName: "Aberdeen", StateId: "103", CityId: '207' },
{ CityName: "Alexandria", StateId: "102", CityId: '204' },
{ CityName: "Albany", StateId: "101", CityId: '201' },
{ CityName: "Beacon ", StateId: "101", CityId: '202' },
{ CityName: "Brisbane ", StateId: "104", CityId: '211' },
{ CityName: "Cairns", StateId: "104", CityId: '212' },
{ CityName: "Colville ", StateId: "103", CityId: '208' },
{ CityName: "Devonport", StateId: "105", CityId: '215' },
{ CityName: "Emporia", StateId: "102", CityId: '206' },
{ CityName: "Geelong", StateId: "106", CityId: '218' },
{ CityName: "Hampton ", StateId: "102", CityId: '205' },
{ CityName: "Healesville ", StateId: "106", CityId: '217' },
{ CityName: "Hobart", StateId: "105", CityId: '213' },
{ CityName: "Launceston ", StateId: "105", CityId: '214' },
{ CityName: "Lockport", StateId: "101", CityId: '203' },
{ CityName: "Melbourne", StateId: "106", CityId: '216' },
{ CityName: "Pasco", StateId: "103", CityId: '209' },
{ CityName: "Townsville", StateId: "104", CityId: '210' }
],
fields: { text: 'CityName', value: 'CityId' },
value: args.EventType,
floatLabelType: 'Always', placeholder: 'City'
});
drowDownList.appendTo(inputEle);
inputEle.setAttribute('name', 'City');
}
} |
// POST: odata/EventDatas
[AcceptVerbs("POST", "OPTIONS")]
public void Post([FromBody]CrudData eventData)
{
EventData insertData = new EventData();
insertData.Id = (db.EventDatas.ToList().Count > 0 ? db.EventDatas.ToList().Max(p => p.Id) : 1) + 1;
insertData.StartTime = Convert.ToDateTime(eventData.StartTime).ToLocalTime();
insertData.EndTime = Convert.ToDateTime(eventData.EndTime).ToLocalTime();
insertData.Subject = eventData.Subject;
insertData.IsAllDay = eventData.IsAllDay;
insertData.Location = eventData.Location;
insertData.Description = eventData.Description;
insertData.State = eventData.State;
insertData.City = eventData.City;
insertData.RecurrenceRule = eventData.RecurrenceRule;
insertData.RecurrenceID = eventData.RecurrenceID;
insertData.RecurrenceException = eventData.RecurrenceException;
insertData.StartTimezone = eventData.StartTimezone;
insertData.EndTimezone = eventData.EndTimezone;
insertData.GuidId = Guid.NewGuid();
db.EventDatas.Add(insertData);
db.SaveChanges();
}
// PATCH: odata/EventDatas(5)
[AcceptVerbs("PATCH", "MERGE", "OPTIONS")]
public void Patch([FromBody]CrudData eventData)
{
EventData updateData = db.EventDatas.Find(Convert.ToInt32(eventData.Id));
if (updateData != null)
{
updateData.StartTime = Convert.ToDateTime(eventData.StartTime).ToLocalTime();
updateData.EndTime = Convert.ToDateTime(eventData.EndTime).ToLocalTime();
updateData.Subject = eventData.Subject;
updateData.IsAllDay = eventData.IsAllDay;
updateData.Location = eventData.Location;
updateData.Description = eventData.Description;
updateData.State = eventData.State;
updateData.City = eventData.City;
updateData.RecurrenceRule = eventData.RecurrenceRule;
updateData.RecurrenceID = eventData.RecurrenceID;
updateData.RecurrenceException = eventData.RecurrenceException;
updateData.StartTimezone = eventData.StartTimezone;
updateData.EndTimezone = eventData.EndTimezone;
updateData.GuidId = eventData.GuidId;
db.SaveChanges();
}
} |
<e-grid-columns>
<e-grid-column field="Id" headerText="Id" isPrimaryKey="true" isIdentity="true" visible="false"></e-grid-column>
<e-grid-column field="OrganisationId" defaultValue="@ViewBag.Organisation.Id" visible="false"></e-grid-column>
<e-grid-column field="IsActive" defaultValue="true" visible="false"></e-grid-column>
Where and how do you do this on the ejs-schedule, I assume its somewhere here?? and what does the syntax look like??
<div class="control-section">
<div class="content-wrapper">
<ejs-schedule id="schedule" width="100%" height="670px" selectedDate=@ViewBag.Today popupOpen="onPopupOpen" popupClose="onPopupClose" editorTemplate="#EditorTemplate">
<e-schedule-eventsettings>
<e-data-manager url="/OData/Appointments"
adaptor="ODataV4Adaptor"
crossDomain="true"
headers='@new Object[]{ new Dictionary<string, object>{ { "organisationid", ViewBag.Organisation.Id} } }'>
</e-data-manager>
</e-schedule-eventsettings>
</ejs-schedule>
</div>
</div>
<ejs-schedule id="schedule" height="100%" selectedDate="new DateTime(2018,10,4)" currentView="Month" popupOpen="onPopupOpen">
<e-schedule-eventsettings query="new ej.data.Query().from('EventDatas')">
<e-data-manager Url="http://localhost:25255/odata" adaptor="ODataV4Adaptor" headers='@new Object[]{ new Dictionary<string, object>{ { "organisationid", ViewBag.organisationId} } }' crossDomain="true">
</e-data-manager>
</e-schedule-eventsettings>
</ejs-schedule> |
<e-grid-columns>
<e-grid-column field="Id" headerText="Id" isPrimaryKey="true" isIdentity="true" visible="false"></e-grid-column>
<e-grid-column field="OrganisationId" defaultValue="@ViewBag.Organisation.Id" visible="false"></e-grid-column>
<e-grid-column field="IsActive" defaultValue="true" visible="false"></e-grid-column>