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

Redirect to an action from Kendo grid

2 Answers 853 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Uttam
Top achievements
Rank 1
Uttam asked on 10 Sep 2012, 01:09 PM
Hello friend,

I am trying to redirect to an action of my controller fro kendo grid but i am unable to do it. can somebody please help me out in this

thanks

2 Answers, 1 is accepted

Sort by
0
Vladimir
Top achievements
Rank 1
answered on 10 Sep 2012, 01:27 PM
$('#manage_managers').delegate('.k-grid-create', 'click', function(e) {
   window.location = 'http://example.com';
});
0
Uttam
Top achievements
Rank 1
answered on 11 Sep 2012, 04:24 AM
Thank you for replying
but i still didn't get exactly what i am looking for
@(Html.Kendo().Grid<Vibrant.Areas.Admin.Models.kenord>().Name("Kendogrid").Columns(column =>
    {
        column.Bound(c => c.order).Width(201);
        column.Bound(c => c.Branch).Width(301);
    }).ClientDetailTemplateId("LoanPolicy").Pageable()
                                           .DataSource(datasource =>   
                                                    datasource.Ajax()
                                                              .Read(read => read.Action("loanbranch","LoanPolicies"))
                                                              .PageSize(10)
                                                               
    ).Sortable()
     .Events(events => events.DataBound("dataBound"))
)
 
 
  
<script id="LoanPolicy" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<Vibrant.Areas.Admin.Models.LoanPol>()
            .Name("Orders_#=Id#")
            .Columns(columns =>
            {
                columns.Bound(c => c.Policy).ClientTemplate("<a href='/Admin/LoanPolicies/Edit?id=#= Id #'>#=Policy#</a>").Title("Policy");
                columns.Bound(c => c.User_Type).Title("User Type");
                columns.Bound(c => c.Info_Type).Title("Info Type");
                columns.Bound(c => c.Period).Title("Period");
                columns.Bound(c => c.Fines).Title("Fine");
                columns.Bound(c => c.Res).Title("Res");
                columns.Bound(c => c.Renew).Title("Renew");
                columns.Bound(c => c.Max_Fine).Title("Max Fine");  
                columns.Command(command => { command.Destroy(); }).Width(100);
                columns.Command(command => command.Custom("Edit").Click("editpolicy")).Width(40);          
            })
            .DataSource(dataSource => dataSource
                .Ajax()
                .Read(read => read.Action("loanpolicy", "LoanPolicies", new { id = "#=Id#" }))
                .Model(model => model.Id(c => c.Id))  
                .Destroy(update => update.Action("Delete", "LoanPolicies"))  
                .PageSize(10)             
            )
             
            .Pageable()
            .Sortable()
            .Filterable()          
            .ToClientTemplate()
    )
</script>
 
<script>
    function dataBound() {
        this.expandRow(this.tbody.find("tr.k-master-row").first());
    }
</script>
from order table i want
on the click of
columns.Bound(c => c.Policy).ClientTemplate("<a href='/Admin/LoanPolicies/Edit?id=#= Id #'>#=Policy#</a>").Title("Policy");

it works for master grid but not for child grid
please suggest me what should i do.


My controller is
public ActionResult Index()
        {
            return View();
        }
 
        public JsonResult loanbranch([DataSourceRequest] DataSourceRequest request)
        {
            var getord = (from q in db.Branches
                          orderby q.Order ascending
                          select new kenord
                          {
                              Id = q.Id,
                              order = q.Order,
                              Branch = q.Description
                          }).ToList();
 
            DataSourceResult getorder = getord.ToDataSourceResult(request);
 
            return Json(getorder, JsonRequestBehavior.AllowGet);
        }
         
 
 
        public JsonResult loanpolicy(int id, [DataSourceRequest] DataSourceRequest request)
        {
            var lonp = (from a in db.LoansPolicies
                        join c in db.InfoTypes on a.InfoTypeId equals c.Id into inftyp
                        from inftypjoin in inftyp.DefaultIfEmpty()
                        join d in db.UserTypes on a.UserTypeId equals d.Id into usrtyp
                        from usrtypjoin in usrtyp.DefaultIfEmpty()
                        join e in db.Branches on a.BranchId equals e.Id
                        orderby a.Type,a.Order ascending
                        where a.BranchId == id                       
                        select new LoanPol
                        {
                            Id = a.Id,
                            Policy = a.Description,
                            User_Type = (a.UserTypeId == 0 ? "*" : usrtypjoin.Description),
                            Info_Type = (a.InfoTypeId == 0 ? "*" : inftypjoin.Description),
                            Period = a.LoanPeriod,
                            Fines = a.FinesAmount,
                            Res = a.ReservationLimit,
                            Renew = a.RenewalLimit,
                            Max_Fine = a.MaxFines
 
                        }).ToList();
            DataSourceResult lonresl = lonp.ToDataSourceResult(request);
 
            return Json(lonresl, JsonRequestBehavior.AllowGet);
        }
everything is working fine except redirection
Tags
Grid
Asked by
Uttam
Top achievements
Rank 1
Answers by
Vladimir
Top achievements
Rank 1
Uttam
Top achievements
Rank 1
Share this question
or