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

Want to pass the Grid Data to Controller in JSON Format

Is it possible to pass the ejGrid Data to Controller in JSON Format?
Tell any other way to save whole grid data..

5 Replies

SR Sellappandi Ramu Syncfusion Team February 24, 2015 10:40 AM UTC

Hi Ganga,

Thanks for using Syncfusion products.

Query #1: Is it possible to pass the ejGrid Data to Controller in JSON Format?

We have analyzed your requirement and created a sample. The sample can be downloaded from following link:

Sample: http://www.syncfusion.com/downloads/support/directtrac/118296/Sample_118296-84222177.zip

In the above sample, we have used button to send the data to controller through AJAX post. When we click the button grid data will send to controller side as string format than converted into JSON format. Please refer the following code snippet.

[cshtml]

 

 function btnClick() {

        var gridmodel = $("#FlatGrid").ejGrid("model");

        var data = JSON.stringify(gridmodel.dataSource);

        $.ajax({

            url: '/Grid/GetData',

            type: 'post',

            data: { data: data },

            success: function (data) {

            }

        })

    }

[Controller]

public Object GetData(string data)

        {

            var gridData = JsonConvert.DeserializeObject(data);

            return gridData;

        }

Query #2: Tell any other way to save whole grid data.

Could you please share the below information to us for sort out the cause of the issue and provide you a response as early as possible?

1. Do you want to save the edited record in server side??

2. Are you using any button to save the bulk data in server side?

Please try the above sample and get back to us with the mentioned details.

Regards,
Sellappandi R



GA Ganga February 26, 2015 10:05 AM UTC

Thanks for your reply ...I ve one more doubt...which event will triggered when filtering the grid???? ..i need the filtered row count to be bind in an textbox while filtering ...


SR Sellappandi Ramu Syncfusion Team February 27, 2015 06:30 AM UTC

Hi Ganga,

Thanks for your update.

Please find the response.

Query

Response

1. which event will triggered when filtering the grid???

The actionComplete event will trigger when we perform any operation on grid. If we need to perform any operation in filter time alone, we need to check the request type as “filtering”.

2. I need the filtered row count to be bind in an textbox while filtering

We have analyzed your requirement and created a sample. The sample can be downloaded from following link:

Sample: EJ_Sample

In the above sample,  we have used actionComplete event to bind the filter record count to text box. Please refer the following code snippet.

function actionComplete(args) {

        if (args.requestType == "filtering") {

            var gridModel = $("#FlatGrid").ejGrid("model");

            if (gridModel.filterSettings.filteredColumns.length) $("#FilteredCount").val(this.getPager().ejPager("option").totalRecordsCount);

            else

                $("#FilteredCount").val("");

        }

    }

Please try the above sample and get back to us if you have any queries.

Regards,

Sellappandi R


GA Ganga February 27, 2015 12:49 PM UTC

Thank u so much sir...It's working fine.


SR Sellappandi Ramu Syncfusion Team March 2, 2015 02:46 PM UTC

Hi Ganga,

Thanks for your update.

Please get back if you require further assistance. We will be glad to assist you.

Regards,

Sellappandi R

Loader.
Live Chat Icon For mobile
Up arrow icon