How to fill dropdown?
I'm struggling with a table that has a dropdown-field to select from one of three pre-defined values. What's the proper way to handle such cases?
(I've created a sample at https://jsplayground.syncfusion.com/f1ne1iii which unfortunately does not reproduce exactly as on my machine )only first cell is shown), but it also exposes the problem of a an empty dropdown-list.
SIGN IN To post a reply.
6 Replies
1 reply marked as answer
GL
Gowri Loganathan
Syncfusion Team
September 15, 2020 11:52 AM UTC
Hi Michael,
Thanks for using Syncfusion Forum.
Query: I'm struggling with a table that has a dropdown-field to select from one of three pre-defined values.
In order to render the grid column as a dropdown while editing we suggest you to define editType as Dropdown which will render the dropDownList with the grid column dataSource Or If you want to bind the external dataSource to the dropdown column we suggest you to use the dataSource property of column.
We need to define the dropdown data value as text and value pair. So, either we can define the dataSource list as text and value pair Or we can define the fields for that column using editParams property. As like below code example.
Query: only first cell is shown in the attached sample
To avoid the reported issue we suggest you to define the fields in Grid dataSource without space. Kindly remove the white space for fields definition in your sample.
Code
|
<body>
<div id="myGrid"></div>
<script type="text/javascript">
var fieldTypes = [
{
"type": "media"
}
……
];
$(function() {
$("#myGrid").ejGrid({
"columns": [
…………. . .
{
"dataSource": fieldTypes, //define the external dataSource for dropdown column here
"editType": ej.Grid.EditingType.Dropdown,
"field":"type",
"editParams":{ fields: {text:"type",value:"type"} }, //define text and value pair to bind external dataSource to the field here
"headerText": "Type",
"isIdentity": false,
"isPrimaryKey": false
}],
dataSource: myGridData,
});
});
</script>
|
Output
Modified sample link: https://jsplayground.syncfusion.com/5gnrbswp
Please refer to the below help documentation links,
Note: In your sample you have used dropdownData in the column definition but we don’t have such property in our Grid column definition so kindly remove it from the column definition. And as we said above, we have dataSource property to define the external dataSource for column.
Kindly revert us for further assistance on this.
Regards,
Gowri V L
Marked as answer
MB
Michael Baas
September 17, 2020 11:19 AM UTC
Excellent - that fixes the problems. Thanks very much!
BTW, the doc @ https://help.syncfusion.com/api/js/ejgrid#ej.Grid.EditingType refers to this as "DropDownList" instead of Dropdown!
Michael
BR
bracknelson
September 18, 2020 05:51 AM UTC
Hey Michael,
You have one dropdown menu, and depending on the user's choice in that one, a second dropdown gets filled with choices. You can use three different ways.
1.Using Text Files.
2. Using JSON Data.
3. Using a Database.
GL
Gowri Loganathan
Syncfusion Team
September 18, 2020 06:55 AM UTC
Hi Michael,
We are happy to hear that the reported issue has been resolved.
Query: doc refers to this as "DropDownList" instead of Dropdown!
We are unable to find the reported issue in the shared link.
But we suspect that we have mentioned EditType as DropDownList in the link below. So, please confirm if you are reporting the below issue or share the correct documentation link.
In the meantime, we will correct the UG(as mentioned above) and refresh it online in our Volume 3 2020 Main release, which is expected to be rolled out by the end of September.
Regards,
Gowri V L
MB
Michael Baas
September 18, 2020 07:32 AM UTC
Thank you - that was exactly the bit that I spoke about :)
MP
Manivannan Padmanaban
Syncfusion Team
September 21, 2020 09:42 AM UTC
Hi Michael,
Thank you for your confirmation.
As we said earlier, in our upcoming release of Volume 3 2020 we will correct the above mentioned UG and refresh it online.
Regards,
Manivannan Padmanaban
SIGN IN To post a reply.
- 6 Replies
- 4 Participants
- Marked answer
-
MB Michael Baas
- Sep 14, 2020 09:07 AM UTC
- Sep 21, 2020 09:42 AM UTC