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

Multi-select field inside a Grid with bugs

Hi,
I tested your samples and recomendations as it was written in
https://www.syncfusion.com/forums/118205/multi-select-field-inside-a-grid
and in
https://www.syncfusion.com/kb/4809/how-to-set-the-multi-select-dropdown-as-edit-type-for-a-column

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/118205/Sample-1576860067.zip
This sample is worked correctly with ej.web.all.min.js  (JavaScript version 12.4.0.24) of ejGrid and ejDropDownList with EditMode.Normal.

But previous version 14.1.0.46 of ejGrid with EditMode.Normal is not called my function read in my code and field "OrderList" with EditTemplate isn't get all new values.
Of course, your line of small print adds clarity in https://www.syncfusion.com/kb/4809/how-to-set-the-multi-select-dropdown-as-edit-type-for-a-column for sample, where not specified EditMode.Batch in EditSettings
.EditSettings (Edit => edit.AllowEditing (). AllowAdding (). AllowDeleting (). EditMode (EditMode.Batch))


Lastest version 14.2.0.26 without split(",") in my function read() forget about the array of objects of type string and converts all in one string, not giving a correct re-edit after saving to database.
With
split(",") it works better, but it does not show in the cell commas between selected values after editing before saving.

Do you plan to fix EditTemplate work for multi-select field in ejGrid
or add
.EditMode (EditMode.Batch) and .split(",") to article
https://www.syncfusion.com/kb/4809/how-to-set-the-multi-select-dropdown-as-edit-type-for-a-column ?

Index2.cshtml:

@(Html.EJ().Grid<object>("Grid")
    .Datasource(((IEnumerable<object>)ViewBag.dataSource))
         .AllowPaging()
             .ToolbarSettings(toolbar =>
                             {
                                 toolbar.ShowToolbar().ToolbarItems(items =>
                                 {
                                     items.AddTool(ToolBarItems.Add);
                                     items.AddTool(ToolBarItems.Edit);
                                     items.AddTool(ToolBarItems.Delete);
                                     items.AddTool(ToolBarItems.Update);
                                     items.AddTool(ToolBarItems.Cancel);
                                 });
                             })
                            .EditSettings(edit => edit.AllowEditing().AllowAdding().AllowDeleting())
        .Columns(col =>
        {

            col.Field("CustomerID").HeaderText("Customer ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Add();
            col.Field("CustomerName").HeaderText("Customer Name").Add();
            col.Field("OrderID").HeaderText("Order ID").Add();
            col.Field("OrderList").HeaderText("Order List").EditTemplate(a => { a.Create("create").Read("read").Write("write"); }).Add();               
                })
)

<script type="text/javascript">
    var dropData = @Html.Raw(Json.Encode(ViewData["data"]))
    function create(args) {
        return "<input>";
    }
    function read(args) {
        return args.ejDropDownList("getValue").split(",");
    }

    function write(args) {
        var selIndex = [];
        if (args.rowdata != undefined)
        {
            for (i = 0; i < args.rowdata["OrderList"].length; i++)
            for (j = 0; j < dropData.length; j++){
                if (args.rowdata["OrderList"][i] == dropData[j].value) {
                    selIndex.push(j);
                    break;
                }
            }
        }
        args.element.ejDropDownList({ width: "100%", dataSource: dropData, fields: { id: "text", text: "text", value: "value" }, showCheckbox: true, allowMultiSelection: true, selectedItems: args.rowdata !== undefined ? selIndex : "" });
    }
</script>

HomeController.cs:
...
        public ActionResult Index2()
        {
            List<OrderData> order = new List<OrderData>();
            List<string> list = new List<string>();
            list.Add("Cream");
            list.Add("Milk");
            list.Add("Eggs");
            list.Add("Butter");
            list.Add("Curd");
            list.Add("yogurt");

            List<string> list1 = new List<string>();
            list1.Add("Cream");
            list1.Add("Eggs");
            list1.Add("Curd");

            List<string> list2 = new List<string>();
            list2.Add("Cream");
            list2.Add("Milk");
            list2.Add("Butter");
            list2.Add("yogurt");

            for (int i = 1; i < 9; i++)
            {
                order.Add(new OrderData(1, "Sam", 2, list));
                order.Add(new OrderData(2, "Mercy", 4, list1));
                order.Add(new OrderData(3, "Jim", 2, list));
                order.Add(new OrderData(4, "Dev", 6, list2));
                order.Add(new OrderData(5, "Jessi", 4, list1));
                order.Add(new OrderData(6, "Cath", 6, list2));
            }

            ViewBag.dataSource = order;

            var drop = list.ToList();
            var dropData = new List<object>();
            foreach (var li in drop)
            {
                dropData.Add(new { value = li, text = li });
            }
            ViewData["data"] = dropData;
            return View();
        }




1 Reply

RU Ragavee U S Syncfusion Team July 14, 2016 12:49 PM UTC

Hi Lev,  

In order to fetch the multi selected items in the read function of edit template, we suggest you to use the jquery split function. But we have considered displaying the selected items as single string in batch edit mode as a bug and a support incident has been created under your account to track the status of this issue. Please log on to our support website to check for further updates.   

Regards,  
Ragavee U S.   


Loader.
Up arrow icon