- Home
- Forum
- ASP.NET MVC
- same values binding when added new records in ejgrid with dropdown controls
same values binding when added new records in ejgrid with dropdown controls
when i added a new record in ejgrid after selecting the different values in drodown template column after save click from edittoolbars same value is binding to dropdown columns.
var wotypelist = @Html.Raw(Json.Encode(Model.lstEquipment.SelectMany(a => a.WorkorderTypes).Where(t => t.Text != null).ToList()));
var WorkordertypeDS = [];
var lengt = wotypelist.length;
for (i = 0; i < lengt; i++)
{
var WoType = {
"text" : wotypelist[i].Text,
"value" : wotypelist[1].Value
};
WorkordertypeDS.push(WoType);
};
var categorylist = @Html.Raw(Json.Encode(Model.lstEquipment.SelectMany(a => a.categories).Where(c => c.Text != null).ToList()));
var categoryDS = [];
var lengt = categorylist.length;
for(i = 0; i < lengt; i++)
{
var caType = {
"text" : categorylist[i].Text,
"value" : categorylist[1].Value
};
categoryDS.push(caType);
};
$(function () {
$("#Equipmentgrid").ejGrid({
dataSource: @Html.Raw(Json.Encode(Model.lstEquipment)),
allowPaging: true,
editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },
toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] },
columns: [
{ field: "SelectedWorkOrderType", headerText: "Work Order Type", editType: ej.Grid.EditingType.Dropdown,dataSource:WorkordertypeDS, foreignKeyField: "value", foreignKeyValue: "text", textAlign: ej.TextAlign.center, validationRules: { required: true, number: true }, width: 90 },
{ field: "SelectedCategory", headerText: "Category", editType: ej.Grid.EditingType.Dropdown,dataSource:categoryDS,foreignKeyField: "value", foreignKeyValue: "text", textAlign: ej.TextAlign.center, width: 90 },
{ field: "EquipmentLocation", headerText: 'Equipment Location', width: 150 },
{ field: "SerialNumber", headerText: 'Serial Number', width: 100 },
{ field: "CatalogID", headerText: 'Catalog ID', width: 90 },
{ field: "Model", headerText: 'Model', width: 90 }
]
});
});
//$("#sampleProperties").ejPropertiesPanel();
function onSelectionTypeChange(args) {
$("#Equipmentgrid").ejGrid("cancelEdit");
$("#Equipmentgrid").ejGrid("model.editSettings.rowPosition", args.selectedValue);
}
SIGN IN To post a reply.
5 Replies
FS
Farveen Sulthana Thameeztheen Basha
Syncfusion Team
June 16, 2016 12:08 PM UTC
Hi Siva,
We have analyzed your code Snippet and created a sample based on your requirements but we are unable to reproduce the issue “dropdown column value gets saved with wrong value”. Please refer the sample attached.
Could you please share us the following details so that we could sort out the cause of the issue and provide a solution as early as possible?
1. Explain you scenario clearly
2. Please share proper replication procedure.
3. Attach Screenshot of the issue.
4. If possible replicate the issue in the above sample and send us back
The provided information will help to analyze the issue and provide you the response as early as possible.
Regards,
Farveen.T
SD
siva dandamudi
June 16, 2016 01:54 PM UTC
i made the datasiurce for Ejgrid dropdown template like below
var wotypelist = @Html.Raw(Json.Encode(Model.lstEquipment.SelectMany(a => a.WorkorderTypes).Where(t => t.Text != null).ToList()));
var WorkordertypeDS = [];
var lengt = wotypelist.length;
for (i = 0; i < lengt; i++)
{
var WoType = {
"text" : wotypelist[i].Text,
"value" : wotypelist[1].Value
};
WorkordertypeDS.push(WoType);
};
and ejgrid binding code like as mentioned in my 1st post.
i tried to add new records in UI like bwlow i mage, what i observed after save btton click dropdowns took last item of dropdowns , product Branding and Frozen Cappuccino are last items in both dropdwons

SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
June 17, 2016 07:39 AM UTC
Hi Siva,
We are able to reproduce the problem at our end with the given code example. While generating the “text” and “value” pair for the “WorkordertypeDS” array, you have wrongly mentioned “1” for the value variable instead of mentioning “i” as variable, which is the cause of the problem. Refer to the following code example and sample.
|
var WorkordertypeDS = [];
var lengt = wotypelist.length;
for (i = 0; i < lengt; i++) {
var WoType = {
"text": wotypelist[i].Text,
"value": wotypelist[1].Value// it must be Ds[i].Value
};
WorkordertypeDS.push(WoType);
} |
After updating the text and value pair with the correct variable “i”, we are able to update the value in the Grid. Refer to the following sample.
Regards,
Seeni Sakthi Kumar S.
SD
siva dandamudi
June 17, 2016 05:41 PM UTC
Thanks for found the mistake , Now it's every thing fine, and i have one more question regarding Styles. in drop down i observed some space with down arrow symbol. i used below css and js files for ej controls. please find the reason.
<link rel='nofollow' href="@Url.Content("~/Content/ejthems/web/default-theme/ej.web.all.min.css")" rel="stylesheet" />
<link rel='nofollow' href="~/Content/ejthems/web/ej.widgets.core.min.css" rel="stylesheet" />
<link rel='nofollow' href="~/Content/ejthems/web/default-theme/ej.theme.min.css" rel="stylesheet" />
<link rel='nofollow' href="~/Content/themes/base/jquery.ui.all.css" rel="stylesheet" />
<link rel='nofollow' href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<link rel='nofollow' href="~/Content/ejthems/web/responsive-css/ej.responsive.css" rel="stylesheet" />
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")
<script src="~/Scripts/jquery-ui.js"></script>
@Scripts.Render("~/bundles/jqgrid")
<script src="~/Scripts/ui.core.js"></script>
<script src="~/Scripts/ui.dropdownchecklist.js"></script>
@Scripts.Render("~/bundles/bootstrap")
<script src="@Url.Content("~/Scripts/jquery.easing.1.3.min.js")"></script>
<script src="@Url.Content("~/Scripts/jsrender.min.js")"></script>
<script src="@Url.Content("~/Scripts/ej/ej.web.all.min.js")"></script>

i
SS
Seeni Sakthi Kumar Seeni Raj
Syncfusion Team
June 20, 2016 10:03 AM UTC
Hi Siva,
We are unable to reproduce the issue at our end. We have prepared a sample with the provided code example reference scripts and css that can be downloaded from the following location.
We could see that you are using Custom CSS for your project. Please share the following information to analyze the issue and provide you solution as early as possible.
1) We could see some bundle config reference. Send the bundle config file to us
2) If possible, replicate the issue in attached sample and send back to us.
3) If you are using any custom CSS. Also share those code too.
Regards,
Seeni Sakthi Kumar S.
SIGN IN To post a reply.
- 5 Replies
- 3 Participants
-
SD siva dandamudi
- Jun 15, 2016 04:27 PM UTC
- Jun 20, 2016 10:03 AM UTC