I am having issue in loading the select options from server using x editable plugin for in place edit.Data in select option is shown as [object object] instead of actual options. Here is my code:
<a href="#" id ="status" data-name="group" data-type="select" data-source='@Url.Action("ProductGroups")' data-value="1" class="editable-click" title="Group">Operator</a>
ProductGroups action returns JSON response in following format [{"value":1,"text":"Default"}] from controller. In controller i am doing this.
public JsonResult ProductGroups()
{
var list = new List<xEditableItem>();
foreach (var item in db.ProductGroups.ToList<ProductGroup>().OrderBy(r=> r.Name))
{
list.Add(new xEditableItem() { value = item.ID, text = item.Name });
}
return Json(list, JsonRequestBehavior.AllowGet);
}
public class xEditableItem { public int value {get;set;} public string text {get;set;} }
I event try passing select options manually like this but the result is the same [object object] in select list.
<a href="#" id ="status" data-name="group" data-type="select" data-source='[{"value":1,"text":"Default"}]' data-value="1" class="editable-click" title="Group">Operator</a>
Problem might be the single quote: From
data-source='@Url.Action("ProductGroups")'
To
data-source="@Url.Action("ProductGroups")"
And you can test passing select options manually: From
data-source='[{"value":1,"text":"Default"}]'
To
data-source="[{"value":1,"text":"Default"}]"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With