Hi,
I am trying to build a solution (PoC) using EJ2 grid. I am getting data from MySQL DB thru' PHP page.
Strangely, when I fetch data from one sample table, the edit->dialog form displays the controls correctly. But when I fetch data from another table, (and with appropriate dialogtemplate added), the edit dialog form shows only #dialogtemplate
Attached a zip file containing:
1) dist - containing javascript / css files I am using
2) dlgorig - This is a test solution using JSON as data source
3) dlgtest - This contains the PoC. The index.html and index.js contains some commented section - this section contains code for 'working' scenario and 'not-working' scenario
4) SrbDB.sql - MySQL DB / table / data creation script
Attachment: tosupport_7e4ce516.zip
|
Index.js
actionComplete: function (args) {
if (args.requestType === 'beginEdit' || args.requestType === 'add') {
var data = args.rowData;
new ej.inputs.NumericTextBox(
{
value: data.EmployeeID,
format: 'C2',
placeholder: 'EmployeeID',
floatLabelType: 'Always',
},
args.form.elements.namedItem('EmployeeID')
);
// Convert Widget for the ShipCountry field
new ej.dropdowns.DropDownList(
{
value: data.LastName,
popupHeight: '300px',
floatLabelType: 'Always',
dataSource: countryData,
fields: { text: 'LastName', value: 'LastName' },
placeholder: 'LastName',
},
args.form.elements.namedItem('LastName')
);
// Convert Widget for the OrderDate field
new ej.calendars.DatePicker(
{
value: data.BirthDate,
placeholder: 'BirthDate',
floatLabelType: 'Always',
},
args.form.elements.namedItem('BirthDate')
);
// Convert Widget for the ShipCity field
if (ej.base.Browser.isDevice) {
args.dialog.height = window.innerHeight - 90 + 'px';
args.dialog.dataBind();
}
// Set initail Focus
if (args.requestType === 'beginEdit') {
args.form.elements.namedItem('FirstName').focus();
} else {
args.form.elements.namedItem('OrderID').focus();
}
}
},
}); |
|
Index.html
<script id="dialogtemplate" type="text/x-template">
<div>
<div class="form-row">
<div class="form-group col-md-6">
<div class="e-float-input e-control-wrapper">
<input id="OrderID" name="OrderID" type="text" value="${OrderID}" ${if(isAdd)} ${else} disabled ${/if} />
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="OrderID">Order ID</label>
</div>
</div>
<div class="form-group col-md-6">
<div class="e-float-input e-control-wrapper">
<input id="FirstName" name="FirstName" type="text" value="${FirstName}" />
<span class="e-float-line"></span>
<label class="e-float-text e-label-top" for="FirstName">FirstName </label>
</div>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<input name="EmployeeID" id="EmployeeID" value="${EmployeeID}" />
</div>
<div class="form-group col-md-6">
<input name="BirthDate" id="BirthDate" >
</div>
</div>
<div class="form-row">
<div class="form-group col-md-6">
<input type="text" name="LastName" id="LastName" value=${if(LastName === null || LastName === undefined)} '' ${else} ${LastName} ${/if} />
</div>
</div>
</div>
</script> |
Hi,
Thanks for your reply.
I have already mentioned in issue, that for one (table) details, it works correctly. It does not work for other table, in spite of giving correct field name
(Refer Index.html in my attachment)
|
var data = new ej.data.DataManager({
url: 'getData.php/?action=getData',
crossDomain: true
}).executeQuery(new ej.data.Query()).then(function(e){
grid.dataSource = e.result;
});
|
Hi,
I have attached a document of issues faced along with screenshots of code, webpage and errors. Please go through and request you to kindly help.
Thanks
Hi,
I have resolved the issue myself. (The data object was empty because form data was empty. Form was not constructed because of a syntax error in template)
The 'if' statement was repeated twice (bold, underlined text below) in 'dialog template' in HTML file which resulted in template error.