We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cascading dropdowns inside Datagrid

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.

4 Replies

PS Pavithra Subramaniyam Syncfusion Team November 15, 2019 11:21 AM UTC

Hi Yoab, 
 
Thanks for contacting Syncfusion support. 
 
We have validated you query at our “Cascading dropdowns inside Datagrid” at our end. 
 
We couldn’t get exact requirement for your query and we assuming  you facing an issue is how to serialize the json data in client side. it’s a common issue. Use below code to serialize the data. 
 
Ex:  @Json.Serialize(ViewBag.Species) 
 
So , we need some below clarification about you query for exact solution. 
 
  1. Confirm your requirement its foreign key column with cascading or not.
  2. Share which type of data source will be using remote or json data.
  3. Share your complete code snippet.
  4. Share your data Source page controller or model.
 
Please get back to us, if you need any further assistance. 
 
Regards, 
Pavithra S. 



YY Yoab Youssoufou November 17, 2019 11:23 AM UTC

Thanks,
It was indeed a serialization issue.
the cascading now works but i have bigger problems now
1) in non edit mode the display in the grid is the value and not the Text, pls find attached picture. in edit mode the dropdownlist behave correctly
2)the CRUD functionality is now lost and giving me errors as though the Id field of the dropdownlist is no longer bound to the control


Attachment: cascading_9ecee5c8.7z


TS Thavasianand Sankaranarayanan Syncfusion Team November 18, 2019 10:23 AM UTC

Hi Yoab, 

Thanks for your update. 

Query 1: In non-edit mode the display in the grid is the value and not the Text, pls find attached picture. in edit mode the dropdownlist behave correctly. 
& 
Query 2: The CRUD functionality is now lost and giving me errors as though the Id field of the dropdownlist is no longer bound to the control. 

We have validated your attached images and queries at our end but we couldn’t get your exact requirement from your data. 

So, please share the below details for further updates. 

  1. Share your complete grid rendering code.
  2. Share your requirements via video demonstration.
  3. Issue reproducing steps.
  4. Share your getting error image for 2nd  query.
  5. Share the stack trace details of script error in console.
 
Regards, 
Thavasianand S. 



YY Yoab Youssoufou November 18, 2019 11:18 AM UTC

Thanks for the assistance,
pls find attached your requests

Attachment: GridError_141c626e.7z

Loader.
Up arrow icon