This is a migrated thread and some comments may be shown as answers.

[Solved] Column custom command not firing

1 Answer 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Daniel Blendea
Top achievements
Rank 1
Daniel Blendea asked on 22 Feb 2012, 11:42 AM
I have the following grid
.DetailView(strikePriceDetails =>
 {
    strikePriceDetails.ClientTemplate(
        Html.Telerik().Grid<OcViewModel>()
        .Name("OC_")
        .ToolBar(toolbar => toolbar.Insert().ButtonType(GridButtonType.Image).
                ImageHtmlAttributes(new { style = "margin-left:0", title = "Add trade" }))
        .DataKeys(keys => keys.Add(x => x.Id))
        .DataBinding(binding =>
        {
            binding.Ajax().Select("Select", "Contracts", new { .. } );
            binding.Ajax().Insert("Save", "Contracts");
            binding.Ajax().Update("Save", "Contracts");
            binding.Ajax().Delete("Delete", "Contracts", new { .. } );
        })
        .Columns(columns =>
        {
            columns.Command(commands => commands.Edit())
            .HtmlAttributes(new { @class = "grid-header", @title = "Edit" });
 
            columns.Command( commands => commands.Delete())
            .HtmlAttributes(new { @class = "grid-header col-delete", @title = "Delete" });
 
            columns.Command( commands => commands.Custom( "closeTrade" )
                .DataRouteValues( route => route.Add( oc => oc.Id ).RouteKey( "TradeId" ) )
                .Ajax( true )
                .Action( "CloseTrade", "Contracts" ) )
                .HtmlAttributes( new { @class = "grid-header col-close", @title = "Close trade" } )
                .HeaderHtmlAttributes( new { @class = "grid-header" } );
             
            columns.Bound( od => od.TradeDate ).HtmlAttributes( new { @class = "col-tradingdate" } );
             
            // other columns
        })
        .Editable(editing => editing.Mode(GridEditMode.PopUp))
        .ClientEvents(events => events.
            OnComplete( "onTradesComplete" ).                                               
            OnDataBinding("...").
            OnDataBound("...").
            OnEdit("...").
            OnSave("...").
            OnRowDataBound("...").
            OnError("..."))
        .Sortable()
        .Footer(false)
        .ToHtmlString()
    );
)
<script type="text/javascript">
    function onTradesComplete(e)
    {
        alert("Trades_onComplete");
        log( "e", e );
        if ( e.name == "closeTrade" )
        {
            var trade = e.response.trade;
            log("trade", trade.TradeDate);
        }
    }
The problem is that for the custom command "closeTrade", all html is rendered but the javascript is not executed, therefore no ajax call is made to the server.

What am I doing wrong?

I'm using the latest version, Q1 2012, released 02/14/2012

1 Answer, 1 is accepted

Sort by
0
Daniel Blendea
Top achievements
Rank 1
answered on 23 Feb 2012, 10:00 AM
I've solved the problem. I forgot to update the javascript files as well.
Maybe it would be a good idea to include the minified versions as resources so they are upgraded in one step.
Tags
Grid
Asked by
Daniel Blendea
Top achievements
Rank 1
Answers by
Daniel Blendea
Top achievements
Rank 1
Share this question
or