Hello,
I've followed your example on cascading dropdowns inside a grid.
var country = [
{ countryName: 'United States', countryId: '1' },
{ countryName: 'Australia', countryId: '2' }
];
var state = [
{ stateName: 'New York', countryId: '1', stateId: '101' },
{ stateName: 'Virginia ', countryId: '1', stateId: '102' },
{ stateName: 'Washington', countryId: '1', stateId: '103' },
{ stateName: 'Queensland', countryId: '2', stateId: '104' },
{ stateName: 'Tasmania ', countryId: '2', stateId: '105' },
{ stateName: 'Victoria', countryId: '2', stateId: '106' }
];
in real life example of course I will be getting the values from a query, I have a working query using a service/DI that workm perfectly in a non cascading grid as shown below:
<e-grid-column field="DepartmentsId" headertext="Department" foreignkeyfield="Id" foreignkeyvalue="Name" datasource="@gen.GetLkDepartments()" width="260" validationrules='@(new Dictionary<string, object> { { "required", true } })'></e-grid-column>
I have tried
var dep = JsonSerializer.Serialize(@gen.GetLkDepartments());
and also
var dep = @gen.GetLkDepartments();
None seem to work, can you please show me how to serialize the json or a simple example on how to make this work this from a database?
My code is a s follows
Interface:
IEnumerable<Departments> GetLkDepartments();
Service:
public IEnumerable<Departments> GetLkDepartments()
{
return _context.Departments.OrderBy(a => a.Name);
}
Thanks in advance for your usual assistance.