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

how to add a custom command with server side handling?

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"

2 Replies

RO robson September 26, 2014 02:32 PM UTC

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


RU Ragavee U S Syncfusion Team September 29, 2014 09:31 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon