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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Getting the Model with all properties during CRUD, not only the properties with their own column in the Grid

Thread ID:





120111 Sep 1,2015 04:23 PM UTC Sep 4,2015 07:17 AM UTC ASP.NET MVC 4
Tags: Grid
Asked On September 1, 2015 04:23 PM UTC

Let's say that I have a Syncfusion grid in my View, and I've enabled CRUD on it. In my Controller, beyond other things, I have:

       public ActionResult PerformUpdate(int key, Model value)
            ...perform update...

            return Json(value, JsonRequestBehavior.AllowGet);

For some reasons, not all model properties are assigned to a certain column in the grid. The problem with this approach is that value properties which haven't been assigned to a column in the grid will be 0 or null (depending on the property being a value or reference type), even if the property actually had a value. 

Is there a way to set up the MVC Grid in such a way that returned model object properties always contain their value, even for properties which haven't been assigned to a column (with the syntax col.Field("prop_name").HeaderText("prop_header").Add(); )?

Replied On September 2, 2015 09:21 AM UTC

Just a quick note to underline the fact that as of now the only solution I see to this problem is to assign each model property to a grid column, so that the property in the model I get from the view during update always hold the current value. Then, to avoid useless column to be displayed I can set their width at 0 (hiding them doesn't work: that has the same effect as not declaring them at all, in respect to model properties). Isn't there really a better way to accomplish this?

Isuriya Rajan [Syncfusion]
Replied On September 2, 2015 12:48 PM UTC

Hi Carlo,
Thanks for contacting Syncfusion support.
We have achieved your requirement by using the ActionBegin event. This event will trigger for every Grid action before its starts.
We can get the current Grid data by using currentViewData property also and can get the editable data via args.data. By using the extend method, two values can be merged.


    function ActionBegin(args) {

        if (args.requestType == "save")

            //Extending the two objects

            var data1 = args.model.currentViewData[args.selectedRow];

            $.extend(args.data, data1);       


We have created a sample that you can download from following link,
Please try the above sample and let us know if it helps. If we misunderstood your query, please provide clear information which will help to provide a prompt solution.


Isuriya R

Replied On September 3, 2015 07:35 AM UTC

Thanks for your kind answer. The solution you provide is almost right: now, I get all the model properties, even if they haven't been assigned to a column. Unfortunately, properties which are going to be changed by the current edit are overwritten with their old values (from var data1 = args.model.currentViewData[args.selectedRow];). Instead, I want to copy from data1 only properties which aren't present in args.data (which should coincide with the properties from the model which haven't been assigned to a column). I think I met the requisite with the following code, which seems to be working (I briefly tested it). Is that ok in your opinion? 

    function ActionBegin(args) {
        if (args.requestType == "save") {
            //retriving all row data
            var allData = args.model.currentViewData[args.selectedRow];

            //extending args.data with the properties from allData
            //which aren't already present in args.data: these are
            //basically the properties which haven't been assigned to
            //a column, and so aren't present in args.data by default
            for (var prop in allData) {
                if (!args.data.hasOwnProperty(prop)) {
                        args.data[prop] = allData[prop];

Balaji Marimuthu [Syncfusion]
Replied On September 4, 2015 07:17 AM UTC

Hi Carlo,

Yes, the provided code example is correct. You can use it. Please get back to us if you need any further assistance. We will be happy to assist you.


Balaji Marimuthu


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon