Hi, Is the custom sorting feature for webhierarchicaldatagrid added in version
Version=11.1.20111.1006 now?
I am binding my webhierarchicaldatagrid to webdatasource which has 3 object datasources like this:
>
/>
="odsScenario_Source"
="odsTaxYear_Source"
out of this I have enabled paging on one of the datasources:
<asp:ObjectDataSource ID="odsPartnership" runat="server"
TypeName="EY.PTAS.Facade.PartnershipFacade" SelectMethod="GetPartnershipData" SelectCountMethod="GetPartnershipDataCount"
OnSelecting="odsPartnership_Selecting" SortParameterName="sortExpression"
EnablePaging="true" onselected="odsPartnership_Selected" >
</asp:ObjectDataSource>
but the sort expression is always blank.
Please let me know if I have missed out anything here and also about the availibility of the feature.
Thanks & Regards,
Megha Dawagni
Hi All,
You are encountering the Cast exception because you will need to implement the IHierarchyData interface when using the ContainerGridDataBinding event. Attached you will find a sample that demonstrates how you can use our WebHierarchicalDataSource (which implements this interface internally) to perform custom sort with this event.
Hope this helps.
Hi
We are facing the same issue after implementing WebdgrdStatements_ContainerGridDataBinding
"Unable to cast object of type 'System.Data.DataRowView' to type 'System.Web.UI.IHierarchyData'
Kindly Suggest as its urgent.
Kind Regards
Vihang
David,
Could you please provide a working code example of ContainerGridDataBinding? I am unable to make it work. At first I wasn't even sure how to cause this event to fire, but then realized that binding WHDG to a dummy dataset that contains a single table with a single row will cause event to fire (please correct me if there's a better way).
Now I am handling it like this:
Protected Sub xMyGrid_ContainerGridDataBinding(sender As Object, e As GridControls.DataBindingEventArgs)
e.Cancel = True
e.DataSource = DisplayCurrentGridPage() e.SelectArguments.TotalRowCount = GetTotalPageNumber()
End Sub
where GetDataForCurrentPage() returns an ADO.NET DataSet. But now I am getting error
"Unable to cast object of type 'System.Data.DataRowView' to type 'System.Web.UI.IHierarchyData'"
Any idea why and how to avoid this? Also am I right in assuming - when I assign "e.SelectArguments.TotalRowCount" - it will affect pager behavior (e.g. total page count) ? And do I still have to handle PageIndexChanged event or "CustomDataBinding" will be automatically called on every page click?
Thanks!
Hi Megha,
Another solution would be to use ContainerGridDataBinding event. This fires CustomDataBinding event of the WDG for all container grids. Here you can cancel the event and then supply the data the grid will bind directly to whatever data you give to the event args. Be warned that you'll need to supply hierarchical data to the container grid which should have info about children.
regards,David Young
Hi Megha Dawagni,
It has been some time since your post but in case that you still need assistance I will be happy to help.
I suggest that you define a custom sorting algorithm in the ‘ColumnSorted’ event of the grid and re-bind the data source:
void WebHierarchicalDataGrid1_ColumnSorted(object sender, Infragistics.Web.UI.GridControls.SortingEventArgs e)
{
e.SortedColumns.Clear();
//Implement custom sorting here
this.WebHierarchicalDataGrid1.DataBind();
}
If you have any other questions please feel free to contact me.