Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> SortingMode=ClientSide problems
 

Pages: 1
LLBLGen Pro Runtime Framework
SortingMode=ClientSide problems
Page:1/1 

  Print all messages in this thread  
Poster Message
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 26-Feb-2008 16:30:41.  
I am using version 2.5 december 5th build. I am binding a gridview to the LLBLGenDataSource2 control and I am having problems sorting on fields that are added to the datatable after FetchTypedList is called. I set liveperistance to false and subscribed to the perform select event so after FetchTypedList is called I can add a column to the datatable to add additional data. When I try to sort the grid by that column I get the excecption - Unable to cast object of type 'SD.LLBLGen.Pro.ORMSupportClasses.EntityProperty' to type 'SD.LLBLGen.Pro.ORMSupportClasses.IEntityField2'.

I have already set the LLBLGenDataSource2 to SortingMode=ClientSide but I still get the exception. If I don't pass the e.Sorter to the FetchTypedList method of the adapter I don't get the exception however nothing gets sorted. What am I doing wrong?

Can some one explain how to sort on SortingMode=Client side when using LivePersistence="False"
Brandt  Top
daelmo
Support Team



Location:
Guatemala City
Joined on:
28-Nov-2005 23:35:24
Posted:
8098 posts
# Posted on: 26-Feb-2008 21:30:34.  
In this case you should add a SortClause using EntityProperty. Something like this:
Code:
Dim MySort As New SortExpression
MySort.Add(New SortClause(New EntityProperty("YourNewColumn"), Nothing, SortOperator.Ascending))
LLBLGenProDataSource2.SorterToUse = MySort


You could see the manual for more details. Wink


David Elizondo
LLBLGen'ing (articles and code snippets) | linkedin | twitter
 
Top
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 26-Feb-2008 22:11:14.  
daelmo wrote:
In this case you should add a SortClause using EntityProperty. Something like this:
Code:
Dim MySort As New SortExpression
MySort.Add(New SortClause(New EntityProperty("YourNewColumn"), Nothing, SortOperator.Ascending))
LLBLGenProDataSource2.SorterToUse = MySort


You could see the manual for more details. Wink



In the performselect method after the button has been pressed, that exact sort expression is already added to the e.Sorter with out me having to add it manuall. Are you are suggesting that I create a SortExpression object and assign it to the SorterToUse property of the datasource control before the PerformSelect is called and this will somehow override the default behavior which correctly populates the sorter with the sort expression to pass to the PerformSelect event? If this is the case do i still pass the e.Sorter to the FetchTypedList method. The manual isn't clear because it doesn't show an example of using LivePersistence="False", SortingMode="ClientSide" and implementing the PerformSelect event.
Brandt  Top
goose
User



Location:
Central America
Joined on:
06-Aug-2007 18:21:05
Posted:
388 posts
# Posted on: 27-Feb-2008 00:12:45.  
how exactly are you adding the fields to the datatable? Can you paste a code snippet?

gansodesoya  Top
Brandt
User



Location:

Joined on:
04-Apr-2007 17:43:03
Posted:
142 posts
# Posted on: 27-Feb-2008 02:01:18.  
goose wrote:
how exactly are you adding the fields to the datatable? Can you paste a code snippet?




Sure thing

Code:

        protected void DS_OnCallSchedules_PerformSelect(object sender, PerformSelectEventArgs2 e)
        {
            e.Filter.PredicateExpression.Add(ScheduleFields.EndTime > DateTime.UtcNow);
            using (IDataAccessAdapter adapter = InfrastructureCentral.BLServices.Adapters.InfrastructureCentral)
            {
                adapter.FetchTypedList(e.ContainedTypedList, e.Filter.PredicateExpression, e.MaxNumberOfItemsToReturn, e.Sorter, e.AllowDuplicates, e.PageNumber, e.PageSize);

                DataTable dt = e.ContainedTypedList as DataTable;
                if (!dt.Columns.Contains("MemberName"))
                {
                    dt.Columns.Add("MemberName", typeof(System.String));
                }
                foreach (DataRow dr in dt.Rows)
                {
                    var individualContactGuid = (Guid)dr[DAL.UpCommingOnCallSchedulesForSupportGroupTypedListFieldIndex.IndividualContactGuid.ToString()];
                    var member = (from m in this._supportGroupMembers.Items
                                 where m.ContactGuid == individualContactGuid
                                 select m).First();
                    dr["MemberName"] = member.Name;
                }
                dt.AcceptChanges();

            }
        }

Brandt  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14569 posts
# Posted on: 27-Feb-2008 11:05:40.  
Quote:
Dim MySort As New SortExpression
MySort.Add(New SortClause(New EntityProperty("YourNewColumn"), Nothing, SortOperator.Ascending))

Don't use the e.Sorter
Rather pass the above mentioned SortExpression to the FetchTypesList method.

Code:
adapter.FetchTypedList(e.ContainedTypedList, e.Filter.PredicateExpression, e.MaxNumberOfItemsToReturn, MySort, e.AllowDuplicates, e.PageNumber, e.PageSize);



  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.