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.
Unfortunately, activation email could not send to your email. Please try again.

Populating a grid locally

Thread ID:

Created:

Updated:

Platform:

Replies:

109264 Jun 5,2013 05:03 AM Jun 11,2013 06:26 AM ASP.NET MVC (Classic) 1
loading
Tags: Grid
Andrea Bioli
Asked On June 5, 2013 05:03 AM

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

Satheeskumar S [Syncfusion]
Replied On June 11, 2013 06:26 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;