This is a migrated thread and some comments may be shown as answers.
Get values from last row in onEdit
7 Answers 97 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
JULIA
Top achievements
Rank 1
JULIA asked on 07 Nov 2010, 09:24 PM

Hello,

how can i recieve the values from the last row inside onEdit (mode == insert)?

Regards,
Timo

7 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Nov 2010, 09:15 AM
Hello Timo,

 Like this :

var grid = $('#Grid').data('tGrid');
var lastRow = gird.$tbody.find(' > tr:last');
var lastItem = grid.dataItem(lastRow);

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
JULIA
Top achievements
Rank 1
answered on 15 Nov 2010, 10:55 AM

Hello,

grid.dataItem(lastRow); always returns undefined. The innerHtml of lastRow is correct.
Is there a problem if the model contains complex properties?

Regards,
Timo

0
Atanas Korchev
Telerik team
answered on 15 Nov 2010, 11:39 AM
Hello Timo,

Unfortunately there was a bug in the official release which prevents this code from working. I am sending you a sample application as well as the patched file.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Craig Tarr
Top achievements
Rank 2
answered on 30 Jun 2011, 06:08 AM
What if you wanted to find a cell in the current row? How would you go about that?

In the Edit I need to get the value of my 7th column and then when I select the ComboBox in the same row (column 3) I need to use the value to filter some items out.

If that's not clear I'll pack up my View and Control later today.
0
Atanas Korchev
Telerik team
answered on 30 Jun 2011, 08:48 AM
Hi Craig Tarr,

 For the current row you can use the dataItem which is supplied in the arguments of the OnEdit event.

All the best,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Craig Tarr
Top achievements
Rank 2
answered on 30 Jun 2011, 01:45 PM
Atanas, thanks!

It was a long night and I knew that one! And I've now have that value in the onEdit.

What I wanted to do with that value was pass it into the Controller and have the ActionResult use the value for additional filtering.

Here's my Grid View.
Html.Telerik().Grid<EntryList>()
            .Name("EntryList")
            .DataKeys(keys =>
            {
                keys.Add(p => p.RaceResultsID);
            })
            .ToolBar(toolbar => {
                toolbar.Insert();
               })
            .DataBinding(dataBinding =>
            {
                dataBinding.Ajax()
                        .Select("_SelectEntryListDrivers", "EntryList")
                        .Update("_UpdateDriver", "EntryList")
                        .Insert("_InsertDriver", "EntryList")
                        .Delete("_DeleteDriver", "EntryList");
            })
            .Columns(columns =>
            {
                columns.Bound(p => p.Name).Width(115);
                columns.Bound(p => p.Car).Width(40);
                columns.Bound(p => p.Manufacturer).Width(75);
                columns.Bound(p => p.Sponsor).Width(175);
                columns.Bound(p => p.Owner).Width(200);
                columns.Command(commands =>
                    {
                        commands.Edit();
                        commands.Delete();
                    }).Width(75).Title("Actions");
                columns.Bound(p => p.PersonID)
                    .ClientTemplate(Html.ActionLink("Person Edit", "Edit", new { area = "util", controller = "Person", ID = "<#= PersonID #>" }, new { target = "_blank", @class = "t-button" }).ToString()).ReadOnly(true).HtmlAttributes("class='t-button'").Title("Utility").Width(75);
                columns.Bound(p => p.RaceResultsID).Width(25).Hidden(true); 
                columns.Bound(p => p.DriverEntity).Width(25).Hidden(true);
                columns.Bound(p => p.OwnerID).Width(25).Hidden(true);
                columns.Bound(p => p.NumberID).Width(25).Hidden(true);
                columns.Bound(p => p.SponsorID).Width(25).Hidden(true);
                columns.Bound(p => p.ManufacturerID).Width(25).Hidden(true);
                columns.Bound(p => p.SubSeriesName).Width(5).Hidden(true);
            })
            .Sortable(sorting => sorting.OrderBy(sortOrder => sortOrder.Add(o => o.Name).Ascending()))
            .Reorderable(reorder => reorder.Columns(true))
            .ClientEvents(events => events.OnEdit("onEdit"))

And p.Name column is actually a ComboBox and that has DataBinding set to an Ajax call. It's inside this Ajax call that I want to take the dataItem in the DriverEntity Column and do some additional filtering. But I wasn't sure how to pass it into the ActionResult.
0
Atanas Korchev
Telerik team
answered on 01 Jul 2011, 06:33 AM
Hello Craig Tarr,

 You can then use the dataItem function of the grid which retrieves the dataItem to which a table row is bound to. Or you can just store the dataItem from the OnEdit event in some variable for later use.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
JULIA
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
JULIA
Top achievements
Rank 1
Craig Tarr
Top achievements
Rank 2
Share this question
or