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.

how to add a custom command with server side handling?

Thread ID:

Created:

Updated:

Platform:

Replies:

117320 Sep 26,2014 07:15 AM Sep 29,2014 05:31 AM ASP.NET Web Forms 2
loading
Tags: Grid
robson
Asked On September 26, 2014 07:15 AM

hello,

I will try to describe this as simple as possible:
I have a working grid,
I want to add a column to it, with a button,
Every record of the grid will have the button,
this button must fire a server side event.
The server side event must have access to the record where the button was.

how can i do this?

ps: im using this library version "Syncfusion.Core, Version=12.2400.0.36"

robson
Replied On September 26, 2014 10:32 AM

I also wanted to let you know that I have extensively searched for something like this in all your online documentation, but didn't find anything for asp.net, there is indeed something for windows form but not for asp.net

Ragavee U S [Syncfusion]
Replied On September 29, 2014 05:31 AM

Hi Robson

 

We have analyzed the reported query.

 

Since we don’t have inbuilt support for performing server side event for custom command, we have logged a feature request. This feature “Need server side event for custom command” will be implemented in any of our feature release.

 

Thus we suggest you to use the following workaround and also to use columnTemplate feature in order to bind a button to the grid rows.

 

Based on your requirement to get the details of the selected record in the button click event, we have created a simple sample and the same can be downloaded from the following location.

 

Sample Link: http://www.syncfusion.com/downloads/support/directtrac/general/Sample-380243146.zip

 

In the above sample, we have explicitly triggered the recordClick event and have passed the arguments for the event in the click event of the button. Please refer the below code snippet.

 

<ej:Grid ID="OrdersGrid" runat="server" AllowPaging="True" RecordClick="RecordClick" OnServerRecordClick="onClick">

<Columns>

            . . .

            <ej:Column HeaderText="Details" Template="true" TemplateID="#buttonTemplate" TextAlign="Center" Width="75"/>           

        Columns>

    ej:Grid>

 

<script type="text/x-jsrender" id="buttonTemplate">

        <button class="Details" name="Details">Detailsbutton>      

    script>

 

<script type="text/javascript">

       

        $(function () {

            $(".Details").ejButton();

            $(".Details").click(function (e) {

                triggerEvent(e);

            });

            });                    

       

        function triggerEvent(e) {

            var obj = $("#OrdersGrid").data("ejGrid");

            var args = { currentTarget: e.currentTarget.name, selectedRecord: obj.getSelectedRecords(), selectedIndex: obj.model.selectedRowIndex };

            obj._trigger("recordClick", args);

        }

       

    script>

 

[In Code Behind]

protected void onClick(object Sender, GridEventArgs e)

        {

            var currentTarget = e.Arguments["currentTarget"];

            var selectedRecord = e.Arguments["selectedRecord"];

            var selectedIndex = e.Arguments["selectedIndex"];

        }

 

Query: “I also wanted to let you know that I have extensively searched for something like this in all your online documentation, but didn't find anything for asp.net, there is indeed something for windows form but not for asp.net”

 

We have created a KB document for the above mentioned requirement and it will be published online tentatively by October 1,2014.

 

Please get back to us if you need any further assistance.

 

Regards

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

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.

;