This question is locked. New answers and comments are not allowed.
I need a non-ajax way of sending some additional (non grid) data. Because this is non ajax it apperas i cannot use the onCommand event to handle the additional data. Can anyone please recommend a way of doing this. Grid snippet below.
columns.Command(commands =>
{
commands.Custom("ViewDetails")
.Text("Details")
.DataRouteValues(route => route.Add(p => p.ProjectGuid).RouteKey("projectGuid"))
.Ajax(false)
.Action("Details", "Project")
.ButtonType(GridButtonType.Text);
}).Width(180).Title("Commands");
6 Answers, 1 is accepted
0
Dadv
Top achievements
Rank 1
answered on 28 Mar 2012, 03:53 PM
Hi,
Where come from p.ProjectGuid ?
Edit: Look at this and tell me if it's what you want ...
Where come from p.ProjectGuid ?
Edit: Look at this and tell me if it's what you want ...
@{ Html.Telerik().Grid<TelerikMvcDemo.Models.MyFile>() .Name("MyFile") .DataKeys(r=>r.Add(p=>p.FileID).RouteKey("FileID")) .ToolBar(commands=> commands.Custom().Url("#").ButtonType(GridButtonType.Text).Text("Refresh").HtmlAttributes(new { @onclick = "refreshTelerikGrid($(this).parent().parent())" })) .Columns(columns => { columns.Bound(f => f.FileID) .ClientTemplate("<input type='checkbox' name='checkedFiles' value='<#=FileID#>' />") .Title("check") .Width(100) .HtmlAttributes(new { style = "text-align:center" }); columns.Bound(f => f.FileID).Width(200); columns.Bound(f => f.FileName).ClientTemplate("<#=FileName#>").Width(200); columns.Bound(f => f.InvoiceNo); columns.Bound(f => f.AddDate).Format("{0:MM/dd/yyyy}").Width(120); columns.Command(c => c.Custom("Details").Action("Index", "Home", new { externalData = "data" }).SendDataKeys(true).ButtonType(GridButtonType.Text).Text("Details")); }) .DataBinding(dataBinding => dataBinding.Ajax() .Select("_CheckBoxesAjax", "MyFile")) .Scrollable() .Sortable() .Pageable(a=>a.PageSize(50)) .Render();}
.Action("Index", "Home", new { externalData = "data" }).SendDataKeys(true) => you can add external data
in the request, you could also add automatically the datakeys for all the commands by adding
.DataKeys(r=>r.Add(p=>p.FileID).RouteKey("FileID"))
0
Phil
Top achievements
Rank 1
answered on 28 Mar 2012, 04:31 PM
Hi Dadv,
Many thanks for response. I'm knee deep in something else at the moment but will try out later and let you know.
ProjectGuid is the key property in my POCO Project class ( a domain entity in my application) by the way.
Phil
Many thanks for response. I'm knee deep in something else at the moment but will try out later and let you know.
ProjectGuid is the key property in my POCO Project class ( a domain entity in my application) by the way.
Phil
0
Dadv
Top achievements
Rank 1
answered on 28 Mar 2012, 04:42 PM
Ok so the same that my FileID in my sample.
Try it, i think it will work like you want.
Try it, i think it will work like you want.
0
Phil
Top achievements
Rank 1
answered on 29 Mar 2012, 12:43 PM
Not sure whether this is what i'm after.
Basically i want to send the values of some textboxes along with the key information when i navigate to the detail.This is primarily so if i navigate back to the search page i can recreae the state of my grid and also the textboxes outside of the grid.
I envisage a piece of javascript that looks up textbox values. however there is no event that fires (non ajax - onCommand is ajax) where i can hook in the data collection.
Where you have externalData = "data"
I need to reach out to text boxes here and get their values and I do not know how to do this.
Regards
Phil
Basically i want to send the values of some textboxes along with the key information when i navigate to the detail.This is primarily so if i navigate back to the search page i can recreae the state of my grid and also the textboxes outside of the grid.
I envisage a piece of javascript that looks up textbox values. however there is no event that fires (non ajax - onCommand is ajax) where i can hook in the data collection.
Where you have externalData = "data"
I need to reach out to text boxes here and get their values and I do not know how to do this.
Regards
Phil
0
Dadv
Top achievements
Rank 1
answered on 29 Mar 2012, 01:21 PM
Server side binding , you need to surround your grid by a form
@using(Html.BeginForm()){
@Html.TextBox("myTextBox")
@Html.Telerik().Grid()....
}
in Ajax binding it's more delicate
@using(Html.BeginForm()){
@Html.TextBox("myTextBox")
@Html.Telerik().Grid()....
}
in Ajax binding it's more delicate
0
Phil
Top achievements
Rank 1
answered on 19 Apr 2012, 10:06 AM
Hi Dadv
I'm returning to this problem. The essence of what you are saying is use the Telerik action method:
.Action("Index", "Home", new { externalData = "data" }).SendDataKeys(true) => you can add external data
My external data is the content of a textbox elsewhere on the page.
I still don't see how i can reach out to that textbox.
I would ordinarily use jquery to get it but i would need to trap an on command event and telerik has made this
event ajax only. So no event seems to fire at the point i click details button and so i have noo hook into collecting up my external data.
How would you replace the new { externalData = "data" }) part of your solution with the contents of a textbox outside of the grid?
Phil
I'm returning to this problem. The essence of what you are saying is use the Telerik action method:
.Action("Index", "Home", new { externalData = "data" }).SendDataKeys(true) => you can add external data
My external data is the content of a textbox elsewhere on the page.
I still don't see how i can reach out to that textbox.
I would ordinarily use jquery to get it but i would need to trap an on command event and telerik has made this
event ajax only. So no event seems to fire at the point i click details button and so i have noo hook into collecting up my external data.
How would you replace the new { externalData = "data" }) part of your solution with the contents of a textbox outside of the grid?
Phil