StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      


«««12345»»»

How do I filter a business object by a custom...Expand / Collapse
Author
Message
Posted 06/25/2008 10:27:20 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
...or in the CurrentDataRefilled event of your BO, you could progammatically add the columns into the CurrentDataTable so that you could filter on this as well:

CurrentDataTable.Columns.Add("MyAggregateField",GetType(Integer))

You could then, in your custom property, store off the value in the Set (or even the Get of the proper if it is readonly):

<Add standard attributes>
Public Readonly Property MyCustomProperty As Integer
   Get
      Me.Item("MyAggregateField") = 1 + 1
      Return CType(me.Item("MyAggregateField"), Integer)
   End Get
End Property

Taking this approach you could then sort and filter on the aggregate field.

Took a while for me to readdress this issue.  I am hitting another brick wall.  I tried adding the column in the method.  If I run a search on the BO, the CurrentDataTable gets refilled again and the column is tried to be readded.  Pop!  Error.  So, I'll check for existence of the column before adding it.

Also, setting the aggregate field to the value of the custom property is tripping me up.  Your VB "Me.Item("MyAggregateField")" is not translating for me in my C# world.  Please let me know where I can access that collection(?). 

Thanks!!
Bill

Post #17368
Posted 06/25/2008 11:01:30 PM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: Today @ 4:52:53 AM
Posts: 4,586, Visits: 4,571
You would just want to reference the Item property of the BO or the Item property of the CurrentDataTable.  The example above is just talking to the BO default property which is the Item collection.  When dealing with a default property, you can access on the root of the object like this:

this["MyAggregateField"] = 1 + 1;

or you could talk straight to the current row:

this.CurrentRow["MyAggregateField"] = 1 + 1;
Post #17369
Posted 06/25/2008 11:16:09 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
Thanks, Trent!

Man, I am getting tired...past midnight here.  Still struggling with this, though.  Looks like I will have to get back to this later.  Gotta sleep.

No Mountain Dew in the house. 

I'll get back with you "tomorrow."
Bill

Post #17370
Posted 06/26/2008 10:46:51 AM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
I added the code below into the CurrentDataTableRefilled method:

CurrentDataTable.Columns.Add("colReqQty", typeof(decimal));

I am checking for the existence before adding.  I then set a filter on the BO to something like this:

MyBO.Filter = "colReqQty > 0";

Nothing.  As a matter of fact, I am getting no value for my Custom Property, at all (named "spxRequiredQty").  Here is my code for the custom property:


public decimal spxRequiredQty
{
   
get
   
{
       
decimal mReqQty = (this.minstocklevel - this.onhandqty) + (this.spxSalesOrderQty - this.spxWorkOrderQty);
       
if (mReqQty < 0) mReqQty = 0;
       
this["colReqQty"] = mReqQty;
       
return mReqQty;
    }
}

I should be able to see a column called [colReqQty] in my BO; however, it does not show up.  For example, I cannot add it to a grid via a BBS.

At the moment, I am quite confused.

Post #17381
Posted 06/26/2008 12:26:45 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
If I put a break on the first line of the code in the custom property, then run the app and open the window that uses the BO, the code NEVER hits this line:

decimal mReqQty = (this.minstocklevel - this.onhandqty) + (this.spxSalesOrderQty - this.spxWorkOrderQty);

What am I doing wrong?  Since the actual custom property is not getting "filled" then the value of my additional column will never get updated.  Therefore, my filter will not work.

This is just viscious! 

  <--- see I am still smiling!!

Perhaps I did not get enough sleep last night.

Post #17388
Posted 06/26/2008 12:38:31 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 10/10/2008 7:28:14 PM
Posts: 1,280, Visits: 3,259
Well, you need to have data in the colReqQty for the filter to work, but your only filling it if/when the custom property is being accessed. Time to rethink this, I'd think

Here are some ideas (in no particular order):
- in your fill method, you could loop through the BO and fill the column by accessing the custom property
- use a method that would fill that column (after adding it) (rather than using the custom property).
- have SQL do the work and return that column

Just do this before you set the filter.

Hope this sparks some ideas (without starting a fire! )
Post #17390
Posted 06/26/2008 12:43:22 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
The fire is already crackling loudly under my feet.  I'll go through those ideas in no particular order. 

Thanks a ton, Greg!
Bill

Post #17391
Posted 06/26/2008 1:07:10 PM


StrataFrame User

StrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame UserStrataFrame User

Group: StrataFrame Users
Last Login: Today @ 7:34:01 AM
Posts: 437, Visits: 1,755
Fascinating.  Bewildering.  Frustrating.

There are three custom properties and one additional column (for the filter).  Prop3 = Prop2 - Prop1 (basically), then ColumnA = Prop3.  Filter ColumnA so that only values greater than 0 are shown.

in your fill method, you could loop through the BO and fill the column by accessing the custom property

Looping through the BO is very time consuming...several minutes to kerchunk each custom prop, then display the grid.  Not a good option.  In addition, the filter did not work even though the column has data!  It shows on the grid.  None of the custom properties show up on the grid...all blank still.

use a method that would fill that column (after adding it) (rather than using the custom property).

That seems to only affect the first row of the BO. 

Both of these last two options made the BO dirty.  Closing the window asked me if I want to save changes.

have SQL do the work and return that column

This is an option (and I have done this for several other BOs)...but, the complexity of the stored procs and UDFs would make the process so slow and painful that it just isn't fun anymore.  Placing the complex code inside of custom class and/or business object really, really makes things a LOT easier (cleaner and neater, too). 

Well, back to the drawing board.  And, in the immortal words of Bill the Cat:

ACK!

Post #17392