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

[Solved] Is there any support for databound events in razor view?

3 Answers 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mc2000
Top achievements
Rank 1
mc2000 asked on 24 Jan 2012, 05:32 PM
I have a grid with "x" number of bound and template columns.

I want to add a title attribute for each data bound row to equal information about that row that is not visible (i.e. Program Length might show in a tooltip over the name of a program). I tried to add it via the onRowDataBoundEvent, which doesn't appear to fire. I am guessing it's because I pass the model back to the view from the server side?!?
<script type="text/javascript">
 
    function onRowDataBound(e) {
 
        $('.ProgramColumn').attr('title', e.dataItem.ProgramLength);
 
    }
 
</script>

What options do I have? Thanks!

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 24 Jan 2012, 06:04 PM
Hello Mark,

The event is fired only when using Ajax Binding and the data is not loaded initially (by passing a collection to the Grid constructor). I am not sure what is your goal, could you share the View content and give an example what you are trying to achieve?

Greetings,
Petur Subev
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
mc2000
Top achievements
Rank 1
answered on 24 Jan 2012, 09:18 PM

Thanks for your reply. My goal is simply to add a tooltip (via the HTML title attribute) or even a jQuery method to show "detailed data".
As I stated in my example, if I am an edu I might have a program:

Intro to Aerobics

On hover, I want to show some detailed information that I might not have in other grid columns

i.e. Cost $20
     Location Denver

These items are a part of my view model, the same exact model I am passing into the grid's constructor. One option would be to just make it a templated column (instead of databound). I could then have something like:

<span title="'" + @item.ProgramCost + "'">@item.ProgramName</span>

but then I lose SORTABILITY on that column!

0
Petur Subev
Telerik team
answered on 25 Jan 2012, 01:12 PM
Hello Mark,

If you bind a column to a property of your model you can still set its Template/ClientTemplate depending on your binding ( columns.Bound(o => o.ProductName).Template(...) ).
This way your column is still sortable/groupable/filterable to your actual property and it is displaying the template you defined.


Greetings,
Petur Subev
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
Tags
General Discussions
Asked by
mc2000
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
mc2000
Top achievements
Rank 1
Share this question
or