PDA

View Full Version : [CLOSED] MVC/Razor Configure a Renderer in a GridPanel



adelaney
May 10, 2012, 2:47 PM
I have a grid where one of the columns needs to be a hyperlink. I have a webforms grid with this code:


<Column>
<Renderer Handler=? return String.format('<a href="javascript:Ext.util.Format.linkClickHandler(\'{0}\ ');" {1}>{2}</a>', url, qTip, display);? />
</Column>

In my new project, I can get this rar in Razor:

colModel.Columns.Add(Html.X.Column().DataIndex("TaskName").Text("Task").CellCls("wideCell").Flex(1).Renderer())

However, there is no "Handler" for the Renderer and the .Renderer property is asking for an Ext.Net.Renderer item (not a delegate) so I don't know how to get the handler information to it. Will you please let me know what I need to provide to complete the link?

Daniil
May 10, 2012, 2:55 PM
Hi,

Example

.Renderer(r =>
r.Handler = "return value;"
)

adelaney
May 10, 2012, 3:13 PM
I don't know that it matters, but I am using VB.NET and I receive an error: "Lamba expression cannot be converted to 'Ext.Net.Renderer' because Ext.Net.Renderer is not a delagate type."

Daniil
May 10, 2012, 3:52 PM
Confirmed, it's really not a delegate type.

It should look this way.

@Html.X().Column().Renderer(new Renderer("return value;"))

adelaney
May 10, 2012, 4:05 PM
Yep, I had pretty much figured that out by the time I received your post, but good to confirm. However, now, I am struggling with how to pass in the record information to provide to my formatter. I have been viewing this example: http://examples2.ext.net/#/GridPanel/Miscellaneous/Custom_UI/ and I have tried using the variables index, value, meta, etc. but they are not recognized as demonstrated in this example. So, how do I get record values?

Daniil
May 10, 2012, 5:15 PM
It this case you should set up Fn.

@Html.X().Column().Renderer(new Renderer() { Fn = "rendererFunction" })

adelaney
May 10, 2012, 7:51 PM
That was the golden ticket. Thanks!