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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Additional parameter to delete query (toolbar item)

Thread ID:

Created:

Updated:

Platform:

Replies:

121183 Nov 17,2015 05:27 PM UTC Nov 25,2015 04:39 AM UTC ASP.NET MVC 3
loading
Tags: Grid
Omar Muscatello
Asked On November 17, 2015 05:27 PM UTC

Hello Syncfusion Team,
I'm using grid control with toolbar items.
On the delete operation, I want to send to controller an additional parameter.

Now, this is my controller:

public JsonResult Delete(int key){
   .....
}

which I want to transform to:

public JsonResult Delete(int key, string additional_key){
   .....
}

In the ToolbarClick event I tried with:

function toolbarClick(sender){
    if(  $(sender.target).hasClass('e-delete')  ){
        this.model.query.addParams('additional_key', 'myvalue');
    }
}

I tried with actionBegin event also.
They doesn't work.

I changed it in 
$("#mytable").ejGrid("model.query", new ej.Query().addParams('additional_key', 'myvalue'));

but it changes the SELECT query.

How can I solve this problem?

And, where I can find documentation for this? Your components are very interesting and I want to study it.

Thank you

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On November 18, 2015 09:43 AM UTC

Hi Omar,

Instead of using the additional parameters, we suggest using the Headers of the ejDataManager. While performing delete action in the actionBegin event, add the required number of array of objects into Headers and retrieve them using the Request Object of the HttpRequestMessage. Please refer to the below code example and screenshot.

@(Html.EJ().Grid<MvcApplication66.OrdersView>("FlatGrid")

        .Datasource(ds => ds.URL("/Home/DataSource").UpdateURL("/Home/Update").RemoveURL("/Home/Delete").Adaptor(AdaptorType.UrlAdaptor))

        .AllowFiltering()

        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })

        .ToolbarSettings(tools =>

                {

                    tools.ShowToolbar().ToolbarItems(items =>

                    {

                         . . . .

                        items.AddTool(ToolBarItems.Delete);

                    }

                        );

                })

        .ClientSideEvents(events => { events.ActionBegin("begin").ActionComplete("complete"); })

        .Columns(col =>

        {

            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();

            . .  . . .

        }))

<script>

    function begin(args) {

        if (args.requestType == 'delete') {

            args.model.dataSource.dataSource.headers = [];

            args.model.dataSource.dataSource.headers.push({ " additional_key": " myvalue" })

        }

    }

    function complete(args) {

        if (args.requestType == 'delete') args.model.dataSource.dataSource.headers = [];//to avoid headers value to be interfered with other actions, emptied the Headers  

    }



</script>

[codeBehind]

public ActionResult Delete(int key)

        {

            var obj = Request.Headers.GetValues("additional_key")[0];

            var data = OrderRepository.GetAllRecords();

            return Json(data, JsonRequestBehavior.AllowGet);
        }




Refer to the following Help Documents for APIs and User Guides.

http://help.syncfusion.com/js/api/ejgrid

http://help.syncfusion.com/aspnetmvc/grid/getting-started

Regards,
Seeni Sakthi Kumar S.

Omar Muscatello
Replied On November 24, 2015 08:54 AM UTC

Thank you very much Seeni Sakthi Kumar Seeni Raj.

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On November 25, 2015 04:39 AM UTC

Hi Omar,
 
We are happy to hear that your issue has been resolved.
 
Get back to us if you need further assistance.
 
Regards,
 
Seeni Sakthi Kumar S.

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.

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

;