PDA

View Full Version : [CLOSED] "GetRowClass" Handler Returns "rowParams" null



cleve
Jan 29, 2013, 12:25 AM
Hi guys,




<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body id="theBody">
<ext:ResourceManager ID="theManager" runat="server"
IDMode="Static"
Theme="Default"
ShowWarningOnAjaxFailure="false"
DirectMethodProxy="Ignore"
ScriptMode="Debug" />
<ext:GridPanel runat="server">
<Store>
<ext:Store runat="server" ID="ds">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="A" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="A" Text="A" />
</Columns>
</ColumnModel>
<View>
<ext:GridView runat="server">
<GetRowClass Handler="window.alert(rowParams);" />
</ext:GridView>
</View>
<Features>
<ext:RowBody runat="server" />
</Features>
</ext:GridPanel>
</body>
</html>
<script runat="server">


protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ds.Data = new List<object>
{
new { A = "1" },
new { A = "2" },
new { A = "3" }
};
ds.DataBind();
}


</script>




It gives "rowParams" null all the time. Anything missing?

Daniil
Jan 29, 2013, 5:01 AM
Hi @cleve,

It is marked "deprecated" in ExtJS 4.1.3.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.Table-method-getRowClass

So, I think it stops functioning in ExtJS 4.2. The SVN trunk currently uses ExtJS 4.2.0 beta 2.

You should use a RowBody's GetAdditionalData handler.

cleve
Jan 30, 2013, 1:25 AM
Hi @cleve,

It is marked "deprecated" in ExtJS 4.1.3.
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.view.Table-method-getRowClass

So, I think it stops functioning in ExtJS 4.2. The SVN trunk currently uses ExtJS 4.2.0 beta 2.

You should use a RowBody's GetAdditionalData handler.

I got how it works. But, as I've viewed example in ExtJS DOC




viewConfig: { getRowClass: function(record, rowIndex, rowParams, store){ return record.get("valid") ? "row-valid" : "row-error"; }}

It presents a way to switch rowCls between "valid" and "invalid". But my code by using GetAdditionalData failed to set the same kind. Could you help me to pick up a little?




<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="/themes/shared.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.testCls, .testCls *
{
background-color:gray;
color:red;
}
</style>
</head>
<body id="theBody">
<ext:ResourceManager ID="theManager" runat="server"
IDMode="Static"
Theme="Default"
ShowWarningOnAjaxFailure="false"
DirectMethodProxy="Ignore"
ScriptMode="Debug" />
<div class="testCls">
CLASS TEST
</div>
<ext:GridPanel runat="server">
<Store>
<ext:Store runat="server" ID="ds">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="A" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column runat="server" DataIndex="A" Text="A" />
</Columns>
</ColumnModel>
<Features>
<ext:RowBody runat="server">
<GetAdditionalData Handler="orig.rowCls='testCls';" />
</ext:RowBody>
</Features>
</ext:GridPanel>
</body>
</html>
<script runat="server">


protected override void OnInit(EventArgs e)
{
base.OnInit(e);
ds.Data = new List<object>
{
new { A = "1" },
new { A = "2" },
new { A = "3" }
};
ds.DataBind();
}


</script>






The "testCls" just can't be cast on row. Appreciate if Daniil can help me :)

Daniil
Jan 30, 2013, 7:58 AM
Well, for this task you should still use a GetRowClass. The "rowParams" should not be required to return a CSS class name from a GetRowClass handler.

cleve
Jan 30, 2013, 10:15 AM
That's it. I am done on this issue. Thanks for the help. Please mark the thread "Closed".

stratadev
Sep 11, 2013, 6:30 PM
I don't believe this issue was ever resolved. The root cause of this issue that I think cleve was trying to get to is that in the extjs source, when using 'GetRowClass' the following happens:



//renderRow in Ext.view.Table
cls = me.getRowClass(record, rowIdx, null, me.dataSource);

//Ext.apply(Ext.grid.View.prototype...
this.getRowClass = function(rec, rowIndex, rowParams, store){
var result = this.__getRowClass(rec, rowIndex, rowParams, store);
if (rowParams.body) { //<-- Always Fails


All I'm trying to do on a standard grid is set a row's style to a modelField called cls that is passed from the server.


<ViewConfig TrackOver="false">
<GetRowClass Fn="function(record){return record.data.cls;}">
</GetRowClass>
</ViewConfig>

As GetRowClass itself is not deprecated I believe this is a bug and should be opened.

As a workaround I've overridden 'renderRow' and am passing an object to me.getRowClass like this:


me.getRowClass(record, rowIdx, 0, me.dataSource);

Although ugly, this way the 'if (rowParams.body)' doesn't always fail.

If there is a better way that accomplishes the same task that does not hit this issue please let me know.

Thanks,
Ryan

Daniil
Sep 12, 2013, 7:08 AM
Hi Ryan,

I cannot see such the code in the SVN trunk.

if (rowParams.body) {

Please clarify what is the Ext.NET version you are using?

stratadev
Sep 12, 2013, 10:32 PM
You are correct. We were still using the ext3 compatibility file and that had the offending code. This can be left as Closed.

Thanks,
Ryan