We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

DataBound (Grouping) Grid and Calculate Formula like Rank

How can you use Calculate formulas like Rank in a DataBound Grid as an Expression field Column. Is this possible? Thanks for your help.

5 Replies

AD Administrator Syncfusion Team June 6, 2005 01:12 PM UTC

In version 3.2 of our GridGroupingControl, we added support for custom functions that you can use in our ExpressionsFields. About midway this forum thread is a discussion of adding custom functions. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=27198 So, you can add a custom function that would get called when the grid computes an expression value. What you would have to do is in your implementation of this cutom function, use an ICalcData obecjt that would be able to use teh Calculate engine to do this calculation. You could do sort of teh same thing using an unbound column technique for both a GridDataBoundGrid or a GridGroupingControl. The problem will be to implement the proper ICalcData object. This implementation will depend upon several things, including the type of grid. For a GridGoupingControl, it would also depend upon whether you need to support grouping and if you want to see the ranking for the whole table or for within groups. It will take some coding to do this.

TH Tobias Hartmann June 16, 2005 11:04 AM UTC

If I use the mentioned public string ComputeFunc(string s) function I get in s the values of a column in one row but not of all the rows within a group. How would I receive those. Thanks for your help.

AD Administrator Syncfusion Team June 16, 2005 01:04 PM UTC

I may not understand what you are asking. You would have to write the code in your method to access these records. For example, if you are using grouping, then you could pass in the group category that you want to rank as the argument in your ComputeFunc method (and maybe some other information as well). Then you could use code like: Group g = this.gridGroupingControl1.Table.TopLevelGroup.Groups[PassedInCategoryString]; // Iterate through g.Records to access the records in this group

TH Tobias Hartmann June 17, 2005 09:43 AM UTC

But I can''t pass a string into the function. If i try to pass a string with a group name, I get the following error "named functions not supported in expressions". If I pass a column "[ColName]" I get the value in the ComputeFunc. So I don''t know in what row of the grid I am and what column I want to process.

AD Administrator Syncfusion Team June 17, 2005 10:13 AM UTC

You cannot pass the string you want into the Rank function, that is true. But you can pass anything you want into YOUR ComputeFunc. There you can take a string like [ColumnName] and convert it into a list of numbers or into a range like A1:A50 that can be understood by the ICalcDataObject that you are using. You will have to do the latter if you want to actually call the CalcEngine''s Rank function. You would have to implement a ICalcDataObject so the CalEngine knows how to map something like A1:A50 into your datasource. We can try to do a sample for you, but it may be a few days before we can get to it. Submit a Direct Trac support incident requesting it if you would like a sample.

Live Chat Icon For mobile
Up arrow icon