Hello,
As you can see, I've made several attempts to create a Command column that routes a certain way (to /orderdetails?orderid=xxx). The first 2 columns do create an ActionLink, but I'm looking for a button. So on the 3rd non-commented column, it does work, but it uses "CartObject.CartSubObject.Property" (which it is getting from the Model, I assume) as the parameter in the Querystring. How can I change this to a pre-defined property like "orderId"?
This is for an ASP.NET MVC 4 application using .NET 4.5.1.
[code]
Html.Kendo().Grid(Model.Orders)
.Columns(columns =>
{
columns.Template(c => @Html.ActionLink("View", "orderdetails", new { orderId = c.CartId }))
//.HtmlAttributes(new { @class = "k-button", @style = "white" })
.Title("View")
.Width(90);
//columns.Command(c => @Html.ActionLink("account", "orderdetails", new { orderId = c..CartId })).Title("View").Width(90);
columns.Bound(m => m.CartId).Template(c => Html.ActionLink("View", "orderdetails", new { id = c.CartId })).Title("Actions")
.ClientTemplate(Html.ActionLink("View", "orderdetails", new { orderId = "id" }).ToHtmlString().Replace("id", "#=CartId#")).Title("Actions");
columns.Command(com => com.Custom("View").Action("orderdetails", "account")).Title("Actions").Width(90);
//columns.Command(com => com.Custom("View").Action("orderdetails", "account", new { orderId = "id" })).Title("Actions").Width(90);
//columns.Bound(o => o.CartId).ClientTemplate(@Html.ActionLink("orderdetails", "account", new { orderId = "#=CartId#" }).ToHtmlString());
//columns.Command(command => command.Custom("View")
// .Click("showDetails"))
// .Title("Actions").Width(90);
columns.Bound(c => c.CartId)
.ClientTemplate
(@Html.ActionLink
("<span class='k-icon k-edit'></span>View",
"orderdetails",
new { id = "#=CartId#" },
new { @class = "k-button k-button-icontext" }).ToHtmlString());
})
.HtmlAttributes(new { style = "max-width: 750px" })
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(o => o.Cart.CartHead.CartID))
.Sort(s => s.Add(a => a.Cart.CartHead.DateSubmitted).Descending())
.PageSize(25)
)
.Sortable()
.Name("OrderHistoryGrid")
.Pageable(pageable => pageable
.Enabled(Model.Orders.Any())
.Numeric(true)
.PreviousNext(true)
.Refresh(true)
.PageSizes(new int[] { 25, 50, 100 })
.ButtonCount(10)
.Messages(m => m.Empty("There are currently no orders affiliated with this account"))
)
.Render();
[/code]
As you can see, I've made several attempts to create a Command column that routes a certain way (to /orderdetails?orderid=xxx). The first 2 columns do create an ActionLink, but I'm looking for a button. So on the 3rd non-commented column, it does work, but it uses "CartObject.CartSubObject.Property" (which it is getting from the Model, I assume) as the parameter in the Querystring. How can I change this to a pre-defined property like "orderId"?
This is for an ASP.NET MVC 4 application using .NET 4.5.1.
[code]
Html.Kendo().Grid(Model.Orders)
.Columns(columns =>
{
columns.Template(c => @Html.ActionLink("View", "orderdetails", new { orderId = c.CartId }))
//.HtmlAttributes(new { @class = "k-button", @style = "white" })
.Title("View")
.Width(90);
//columns.Command(c => @Html.ActionLink("account", "orderdetails", new { orderId = c..CartId })).Title("View").Width(90);
columns.Bound(m => m.CartId).Template(c => Html.ActionLink("View", "orderdetails", new { id = c.CartId })).Title("Actions")
.ClientTemplate(Html.ActionLink("View", "orderdetails", new { orderId = "id" }).ToHtmlString().Replace("id", "#=CartId#")).Title("Actions");
columns.Command(com => com.Custom("View").Action("orderdetails", "account")).Title("Actions").Width(90);
//columns.Command(com => com.Custom("View").Action("orderdetails", "account", new { orderId = "id" })).Title("Actions").Width(90);
//columns.Bound(o => o.CartId).ClientTemplate(@Html.ActionLink("orderdetails", "account", new { orderId = "#=CartId#" }).ToHtmlString());
//columns.Command(command => command.Custom("View")
// .Click("showDetails"))
// .Title("Actions").Width(90);
columns.Bound(c => c.CartId)
.ClientTemplate
(@Html.ActionLink
("<span class='k-icon k-edit'></span>View",
"orderdetails",
new { id = "#=CartId#" },
new { @class = "k-button k-button-icontext" }).ToHtmlString());
})
.HtmlAttributes(new { style = "max-width: 750px" })
.DataSource(dataSource => dataSource
.Server()
.Model(model => model.Id(o => o.Cart.CartHead.CartID))
.Sort(s => s.Add(a => a.Cart.CartHead.DateSubmitted).Descending())
.PageSize(25)
)
.Sortable()
.Name("OrderHistoryGrid")
.Pageable(pageable => pageable
.Enabled(Model.Orders.Any())
.Numeric(true)
.PreviousNext(true)
.Refresh(true)
.PageSizes(new int[] { 25, 50, 100 })
.ButtonCount(10)
.Messages(m => m.Empty("There are currently no orders affiliated with this account"))
)
.Render();
[/code]