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

[Solved] Custom Column not behaving as expected...

0 Answers 73 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.
David
Top achievements
Rank 1
David asked on 26 Apr 2012, 11:17 AM
Hi

I have a custom column in my Grid (see below).

@(
    this.Html.Telerik().Grid<InspireWebServices.ClientRow>(this.Model._ClientAndPromotionDataOut._ClientRows)
        .Name("ClientsGrid")
        .DataBinding(DB => { DB.Server().Select("_Clients", new { ajax = true }); DB.Ajax().Select("__Clients"); })
        .ClientEvents(events => events.OnComplete("ClientsGrid_OnComplete"))
        .Columns(C =>
        {
            C.Bound(client => client.iClient_ID).Title("Client ID").Width(125);
            C.Bound(client => client.vClient_Name).Title("Client Name").Width(300);
            C.Command(commands => commands.Custom("EditCommand").Text("Edit").DataRouteValues(route => route.Add(CR => CR.iClient_ID).RouteKey("iClient_ID")).Ajax(true).Action("_EditClient", "ExChronos")).Width(80);
        })
        .TableHtmlAttributes("style='height: 400px;'")
        .Scrollable(S => S.Enabled(true).Height("100%"))
        .Sortable(S => S.Enabled(true))
        .Pageable(P => P.PageSize(10))
        .Filterable()
        .Selectable()
        .Footer(true)
)

When this custom column completes I would like it to open an edit window. However, it does not do this it opens a download window (Using IE 8) and the onComplete event does not fiire.

the javascript for this problem is as below...

@(
    this.Html.Telerik().Window()
        .Name("Client")
        .Visible(false)
        .Title("Client Details")
        .Modal(true)
        .Width(500)
        .Height(200)
        .Content(@<text>
                        <div id="client-details">
                            <img />
                        </div>
                  </text>)
)
<script language="javascript" type="text/javascript">
    function PageSize_DropDownListChange() {
        var oDropDownList = jQuery("#PageSize").data("tDropDownList");
        var oGrid = jQuery("#ClientsGrid").data("tGrid");
        oGrid.pageSize = oDropDownList.value();
        oGrid.ajaxRequest();
    }
    function ClientsGrid_OnComplete(e) {
       alert('Hi!');
       if (e.name == "EditCommand")
       {        
            var detailWindow = jQuery("#Client").data("tWindow");
            var oClient = e.response.Client;
            jQuery("#client-details")
                .find("img")
                .attr("src", '@Url.Content("~/frontend/images/disslogo.gif")')
                .end();
            detailWindow.center().open();   
       
   }    
</script>

The Controller that serves this page is...

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
  
public class ExChronosController : Controller
{
    private string _WebServicePassword = "TjBdsAurgQFZg0yGcXZXdbpqEpN3rfK0";
  
    private _ClientsModel GetClients()
    {
        _ClientsModel loClientsModel = new _ClientsModel();
        using (InspireWebServices.Service1SoapClient loService = new InspireWebServices.Service1SoapClient())
        {
            loClientsModel._ClientAndPromotionDataOut = loService._GetClientAndPromotion(new InspireWebServices.Security() { _Client = "Diss Internal", _Password = _WebServicePassword });
            loService.Close();
            return loClientsModel;
        }
        return null;
    }
  
    public ActionResult _Clients()
    {
        _ClientsModel loModel = this.GetClients();
        return this.View(loModel);
    }
  
    [GridAction]
    public ActionResult __Clients()
    {
        _ClientsModel loModel = this.GetClients();
        return this.View(loModel);
    }
  
    public JsonResult _EditClient(int iClient_ID)
    {
        InspireWebServices.ClientRow loClientRow = null;
        _ClientsModel loModel = this.GetClients();
        InspireWebServices.ClientRow[] loClientRows = loModel._ClientAndPromotionDataOut._ClientRows.Where<InspireWebServices.ClientRow>(CR => CR.iClient_ID == iClient_ID).ToArray<InspireWebServices.ClientRow>();
        if (loClientRows.Length == 1)
        {
            loClientRow = loClientRows[0];
        }
        return Json(new { Client = loClientRow }, JsonRequestBehavior.AllowGet);
    }
}


Can you please let me know what I am doing wrong.

Thanks

David
Tags
Grid
Asked by
David
Top achievements
Rank 1
Share this question
or