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.

Want to pass the Grid Data to Controller in JSON Format

Thread ID:

Created:

Updated:

Platform:

Replies:

118296 Feb 21,2015 03:22 AM Mar 2,2015 09:46 AM ASP.NET MVC 5
loading
Tags: Grid
Ganga
Asked On February 21, 2015 03:22 AM

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

Sellappandi Ramu [Syncfusion]
Replied On February 24, 2015 05:40 AM

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


Ganga
Replied On February 26, 2015 05:05 AM

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 ...

Sellappandi Ramu [Syncfusion]
Replied On February 27, 2015 01:30 AM

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

Ganga
Replied On February 27, 2015 07:49 AM

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

Sellappandi Ramu [Syncfusion]
Replied On March 2, 2015 09:46 AM

Hi Ganga,

Thanks for your update.

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

Regards,

Sellappandi R

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.

;