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

Foreign Key column editor help

13 Answers 219 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Bob
Top achievements
Rank 1
Bob asked on 05 Jan 2012, 09:44 PM
I have a grid in which I set up a foreignkey column. The grid displays properly and shows the value in the column.

However, when I click in the cell to edit it, the dropdown displays the wrongly selected value and it also doesn't drop down... like it is disabled perhaps. 

I am using Ajax binding so I can do batch editing, if that makes and difference.

Any ideas?

I'm not sure if even this will fix the issue, because I need the drop down list to be filtered based on another field in the row of the grid. I didn't see any examples of this. Some type of ajax binding for the dropdown list is probably needed, but I'm not sure how to do that in this situation.

thanks,
BOb

13 Answers, 1 is accepted

Sort by
0
Unik
Top achievements
Rank 1
answered on 09 Jan 2012, 11:08 PM
Check in your Views/Shared/EditorTemplates if you have GridForeignKey.ascx.

It's the template and I upgrade from previous version and it was'nt there.

You can find it in program files/telerik etc...

For filtered i think nothing was built in for that.

Hope this help
0
Daniel
Telerik team
answered on 10 Jan 2012, 09:52 AM
Hello,

Yes the GridForeignKey editor template is required when using the ForeignKey Column feature.
I attached a project which implements two cases:
  1. Grid in Batch editing mode which uses a ForeignKey Column.
  2. Grid in Batch editing mode with a ForeignKey Column which is filtered based on another field.

Don't hesitate to ask if you have any questions.

All the best,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Bob
Top achievements
Rank 1
answered on 10 Jan 2012, 08:14 PM
Thanks... that helps much. Questions/issues.

1. How would I support more than 1 fk column in the grid when I am filtering the pick lists? This same code seems to be hit (selector returns an element) no matter which fk cell I am editing. I tried a few things but couldn't figure it out. 

2. Is there a way for me to attach a data- value to the dropdown list and access it in this JS so I can send it with the ajax request?

3. When the onedit fires for an added row the dataItem doesn't seem to contain the entered value in the field I need to get the filter value from. 

BOb

0
Bob
Top achievements
Rank 1
answered on 11 Jan 2012, 10:12 PM
1. Ok, I figured out how to get the id of the dropdown list using $(".t-dropdown input", e.cell).attr("id"). So problem solved there.

2. Still would like to know how to do this. I can use HtmlAttributes but that gets added to the td rather than the input. I guess I could figure out how to drill up to the td and get it. Basically it is a parameter I want to pass to the action method. 

3. This seems to be working fine now. Not sure what was going on.

BOb
0
Daniel
Telerik team
answered on 12 Jan 2012, 03:58 PM
Hi Bob,

The DropDownList is create dynamically, on-demand . Therefore,  there is no way to add a value to it that can be retrieved later. The table cell element could be used for that purpose. It can be retrieved directly from the OnEdit event argument's cell property.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Bob
Top achievements
Rank 1
answered on 12 Jan 2012, 06:59 PM
Thanks... that works perfectly.

BOb
0
Rajesh
Top achievements
Rank 1
answered on 05 Apr 2012, 11:29 AM
Hi Daniel,

I have a related, though different issue. I need to trap the OnChange event for the drop down list itself (which is created when i try to edit a column bound using the ForeignKey method).

ForeignKeyColumn.OnChange --> I need to enable/disable certain cells in the row depending on the value selected by the user.
0
Cris
Top achievements
Rank 1
answered on 20 Aug 2012, 10:34 AM
Hi Daniel,

In the attached project (in JustForeignColumnKey view) the rows are marked as dirty (red indicator) even you do not change the cell value (click on Category Id column and then leave the cell without changing anything).
Is there a way to prevent this behaviour ?

Thank you,
Cristian
0
Daniel
Telerik team
answered on 23 Aug 2012, 06:31 AM
Hi,

The dirty indicator is added because the value returned from the DropDownList is string and the one in the model is number. In order to avoid this you could handle the OnSave event and parse the string back to a number when the ForeignKey field is edited e.g.

function Save(e) {
    if (e.values.CategoryID) {
        e.values.CategoryID =  parseInt(e.values.CategoryID);
    }
}
Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
JORGE
Top achievements
Rank 1
answered on 30 Sep 2012, 09:05 PM
I´m sorry if I can´t help you. Could you help me please?
I´m trying with ForeignKey grid, but don´t work. Have you some example functional?
I´m following the example on the Telerik site, but don´t run whit me.

Tks a lot.

0
Daniel
Telerik team
answered on 02 Oct 2012, 03:25 PM
Hello Jorge,

You can check the example attached to this thread. 

Regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
0
Martin Moesby
Top achievements
Rank 2
answered on 15 Nov 2012, 12:33 PM
Nothing happens, when I try to retrieve the attached example ?
0
Martin Moesby
Top achievements
Rank 2
answered on 15 Nov 2012, 07:11 PM
Nevermind, apparently something was of with either the network I was on, or the computer i was using - file fethed and examined.

Thx
Tags
Grid
Asked by
Bob
Top achievements
Rank 1
Answers by
Unik
Top achievements
Rank 1
Daniel
Telerik team
Bob
Top achievements
Rank 1
Rajesh
Top achievements
Rank 1
Cris
Top achievements
Rank 1
JORGE
Top achievements
Rank 1
Martin Moesby
Top achievements
Rank 2
Share this question
or