I have a search page for Cars where the results are put in a Telerik Grid. There is an ajax call made to my API controller which returns result. The success function of my ajax call is as shown:
The function CarSearchResultsToGrid is shown below:
I then have the following code in a PartialView
What I am trying to achieve which is not working currently is to have a button or clickable link on each row in the final column with the Title of that column being Create New Car Report and the Button or Hyperlink in each row just saying 'Create'. I had tried to add the columns.Commad as shown above but it is not working. What I need is for the Button or Link to be added to each row - On clicking either the link or button the User will be Navigated to another page - so I would like to Hit an Action method in a controller - and to the action on the controller I want to pass some data from the row on which the button was clicked - so I would like to pass the CarNumber which will be unique on each row, I would like to pass the OwnerName and finally the ManaufacturerName - can anyone help as to achieve this?
Many Thanks
success:
function
(result) {
CarSearchResultsToGrid(result,
"carSearchGridResults"
);
}
The function CarSearchResultsToGrid is shown below:
function
CarSearchResultsToGrid(result, gridId) {
var
dataSource =
new
kendo.data.DataSource({
data: result,
pageSize: 10
});
$(
"#"
+ gridId).data(
"kendoGrid"
).setDataSource(dataSource);
}
I then have the following code in a PartialView
@(Html.Kendo().Grid<CarSearchl>()
.Name(
"carSearchGridResults"
)
.Columns(columns =>
{
columns.Bound(c => c.CarNumber)
.Width(60);
columns.Bound(c => c.OwnerName)
.Width(100);
columns.Bound(c => c.Colour)
.Width(100);
columns.Bound(c => c.FuelType)
.Width(80);
columns.Bound(c => c.LastServiceDate)
.Format(
"{0:dd/MM/yyyy}"
)
.Width(50);
columns.Bound(c => c.ManufacturerName)
.Width(80);
columns.Command(command =>
{
command.Edit();
command.Custom(
"Create"
).Click(
"PropertyPage.DeleteProperty"
);
})
.Title(
"Create New Car Report"
)
.Width(166);
})
.Pageable(pageable => pageable
.PageSizes(
true
)
.ButtonCount(5))
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(a => a.CarNumber))
.Update(update => update.Action(
"Create"
,
"Property"
))
)
)
What I am trying to achieve which is not working currently is to have a button or clickable link on each row in the final column with the Title of that column being Create New Car Report and the Button or Hyperlink in each row just saying 'Create'. I had tried to add the columns.Commad as shown above but it is not working. What I need is for the Button or Link to be added to each row - On clicking either the link or button the User will be Navigated to another page - so I would like to Hit an Action method in a controller - and to the action on the controller I want to pass some data from the row on which the button was clicked - so I would like to pass the CarNumber which will be unique on each row, I would like to pass the OwnerName and finally the ManaufacturerName - can anyone help as to achieve this?
Many Thanks