Populating a grid locally

I didn't have the time to excercise with the trial, but I would like to know if with this grid it's possible to populate a local grid with data coming from the server.
To make an example, let's suppose that I have a table on the server with the possible hobbies. On the client, the user can insert a record about himself (name, birthday, etc.) *and* add the list of his hobbies, choosing from the server.
Technically speaking, I think we can call it 'model binding to a collection attribute'. All happens in the client, and when the user submit the form, in the controller I have all the data, including the list. Is it possible?
Thanks in advance
Andrea

1 Reply

SS Satheeskumar S Syncfusion Team June 11, 2013 10:26 AM UTC

Hi Andrea,


Thanks for your interest in Syncfusion products.

We glad to inform you that your requirement can be achieved using the below code snippet.


[Script]
<script type="text/javascript">

    $(function()
    {
            $('#DialogEditSave').click(function ()
            {
                    var select = $('#Hobby');
                var arr = [];    
                $('#Hobby option:selected').each(function ()
                {
                        arr.push($(this).val());
                });
                $('#Hobbies').val(arr);
            }).change();
    })

</script>


[EditorTemplate.cshtml]

    @Html.ListBox("Hobby", ViewData["hobbieslist"] as MultiSelectList)

    @Html.Hidden("Hobbies")
                  

[EditingController.cs]

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult OrderSave(EditDetails ord, string[] Hobbies)
{       
         string hoby=string.Join("", Hobbies);
         ViewData["hobbieslist"] = GetHobbies(hoby.Split(','));
         ord.Hobby = hoby;    
         DetailsRepository.Update(ord);
         var data = DetailsRepository.GetAllRecords();
         return data.GridJSONActions<EditDetails>();
}


           
For your convenience we have attached a sample. Could you use that sample and get back to us if you have any queries.

Let us know if you have any concerns.


Regards,
Satheeskumar S



populate_b9184e46.zip

Loader.
Up arrow icon