LLBLGen datasource without LivePersistence and callbacks -> refreshing the grid

Posts   
 
    
Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 17-Nov-2008 22:20:37   

Hi,

I'm using DevExpress' component suite, and created a page which includes an ASPxCallbackPanel around an ASPxGridView (with LivePersistence = false) & an LLBLGen datasource bound to this grid.

I'm firing this callback from elsewhere on the page where users can add to this grid (usign other LLBLGen entities) and "refresh" it to see these changes. This all works fine when the page first loads, however the only way I could get the PerformSelect() to re-fire when DataBind() was called on the grid from the callback was to set the Refetch property to true prior to this, i.e.

myLLBLGenDataSource.Refetch = true; // without this line, the PerformSelect doesn't occur myGrid.DataBind();

Is this the expected practice, or am I missing something? Thanks.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 18-Nov-2008 05:17:04   

Could be related to this ? http://llblgen.com/TinyForum/Messages.aspx?ThreadID=12343 Could you show us your aspx of the grid and llblgenprodatasource? LLBLGen version and runtime library version?

David Elizondo | LLBLGen Support Team
Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 19-Nov-2008 00:01:58   

Hi David

Thanks - that link is similar but unlike this situtation setting Refetch=true does "work" for me - so thats all good simple_smile . But without setting this property the grid simply refreshes followign a <gridname>.DataBind() call, and the PerformSelect event doesn't get fired.

LLBL Version 2.6, runtime: v2.0.50727

Both the ASPxGrid + LLBLDataSource are enclosed within an ASPxCallbackPanel - which gets its callback fired elsewhere by a button via clientside javascript.

LLBLGen datasource2 aspx


 <llblgenpro:LLBLGenProDataSource2 runat="server" EntityFactoryTypeName="OrYx.TVShopping.TMS.FactoryClasses.ScheduleEntityFactory, OrYx.TVShopping.TMS" 
    AdapterTypeName="OrYx.TVShopping.TMS.DatabaseSpecific.DataAccessAdapter, OrYx.TVShopping.TMSDBSpecific" LivePersistence="False" DataContainerType="EntityCollection" CacheLocation="Session" ID="dsSchedule" 
    OnPerformSelect="dsSchedule_PerformSelect" 
    OnPerformGetDbCount="dsSchedule_PerformGetDbCount">
 </llblgenpro:LLBLGenProDataSource2>

CS behind events:


        protected void dsSchedule_PerformGetDbCount(object sender, PerformGetDbCountEventArgs2 e) {
            DataAccessAdapter adapter = new DataAccessAdapter();
            e.DbCount = adapter.GetDbCount(e.ContainedCollection, e.Filter);
        }

        protected void dsSchedule_PerformSelect(object sender, PerformSelectEventArgs2 e) {
            // setup pre-fetch resource and segment data
            IPrefetchPath2 mySchedulePrefetchPath = new PrefetchPath2((int)EntityType.ScheduleEntity);
            mySchedulePrefetchPath.Add(ScheduleEntity.PrefetchPathResource);
            mySchedulePrefetchPath.Add(ScheduleEntity.PrefetchPathSegment);

            // setup filter criteria - only return schedule items for this day
            DateTime myScheduleDate = edtScheduleDate.Date;
            IPredicateExpression myFilter = new PredicateExpression(ScheduleFields.ScheduleDate == myScheduleDate);
            IRelationPredicateBucket myScheduleFilter = new RelationPredicateBucket(myFilter);

            // setup sorting 
            ISortExpression myScheduleSorter = new SortExpression(ScheduleFields.OrderNo | SortOperator.Ascending);

            // load schedule and related entities
            using (DataAccessAdapter adapter = new DataAccessAdapter()) {
                adapter.FetchEntityCollection(e.ContainedCollection, myScheduleFilter, e.MaxNumberOfItemsToReturn, myScheduleSorter, mySchedulePrefetchPath, e.PageNumber, e.PageSize);
            };

            // determine "start" time thru each day
            RecalculateStartTimes();
        }

ASPxGridView aspx:


<dxwgv:ASPxGridView runat="server" ClientInstanceName="grdSchedule" CssFilePath="~/App_Themes/Glass/{0}/styles.css" CssPostfix="Glass" KeyFieldName="ScheduleId" AutoGenerateColumns="False" DataSourceID="dsSchedule" Width="100%" ID="grdSchedule" __designer:wfdid="w47" OnHtmlRowPrepared="grdSchedule_HtmlRowPrepared" OnHtmlDataCellPrepared="grdSchedule_HtmlDataCellPrepared">
<ClientSideEvents RowClick="function(s, e) {
    //Clear the text selection
    _aspxClearSelection();
    //Unselect all rows
    grdSchedule._selectAllRowsOnPage(false);
    //Select the row
    grdSchedule.SelectRow(e.visibleIndex, true);    
}"></ClientSideEvents>
<Columns>
<dxwgv:GridViewCommandColumn ShowSelectCheckbox="True" Width="2%" Visible="False"></dxwgv:GridViewCommandColumn>
<dxwgv:GridViewDataTextColumn FieldName="OrderNo" SortIndex="0" SortOrder="Ascending" Width="3%" Caption="Ord" ToolTip="Schedule Order No" VisibleIndex="0">
<Settings AllowSort="True"></Settings>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="StartTime" Width="6%" Caption="Start Time" VisibleIndex="1"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="LouthId" Width="12%" Caption="Louth Id" ToolTip="Program/Segment Louth Id" VisibleIndex="2"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="SegmentNo" Width="4%" Caption="Seg No" ToolTip="Segment No" VisibleIndex="3">
<CellStyle HorizontalAlign="Center"></CellStyle>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="FullTitle" Width="35%" VisibleIndex="4"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ResourceTypeCode" Width="8%" Caption="Type" VisibleIndex="5"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="Duration" Width="5%" ToolTip="Program/Segment Duration" VisibleIndex="6">
<CellStyle HorizontalAlign="Right"></CellStyle>
</dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataDateColumn FieldName="ScheduleDate" Width="5%" Visible="False"></dxwgv:GridViewDataDateColumn>
<dxwgv:GridViewDataTextColumn FieldName="ScheduleId" ReadOnly="True" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ResourceId" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="SegmentId" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="Gap" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="BookingActive" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="SegmentDuration" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ResourceDuration" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="ResourceLouthId" Visible="False"></dxwgv:GridViewDataTextColumn>
<dxwgv:GridViewDataTextColumn FieldName="SegmentLouthId" Visible="False"></dxwgv:GridViewDataTextColumn>
</Columns>
<SettingsBehavior AllowSort="False"></SettingsBehavior>
<SettingsPager PageSize="50" Position="TopAndBottom" NumericButtonCount="50"></SettingsPager>
<Settings ShowTitlePanel="True"></Settings>
<SettingsText Title="Schedule Title"></SettingsText>
<Images ImageFolder="~/App_Themes/Glass/{0}/">
<CollapsedButton Height="12px" Width="11px"></CollapsedButton>
<DetailCollapsedButton Height="9px" Width="9px"></DetailCollapsedButton>
<FilterRowButton Height="13px" Width="13px"></FilterRowButton>
<PopupEditFormWindowClose Height="17px" Width="17px"></PopupEditFormWindowClose>
</Images>
<Styles CssPostfix="Glass" CssFilePath="~/App_Themes/Glass/{0}/styles.css">
  <Header SortingImageSpacing="5px" ImageSpacing="5px"></Header>
  <TitlePanel Font-Bold="True"></TitlePanel>
</Styles>
</dxwgv:ASPxGridView>

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 09:26:14   

LLBL Version 2.6, runtime: v2.0.50727

That's not a correct runtime version number (build no.). Please check David's link.

Anyway what you have described is a normal behaviour. As the LLBLGenDataSource would issue a re-fetch if something was changed, like the specified filter, or if a Save or Delete have been issued by it, so it knows that data has changed. But if nothing seems to be changed and still you want to do a refetch, then you have to set the flag.

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 19-Nov-2008 09:38:50   

Ok if this is expected behaviour, then thats fine. You are right, no db operation is occuring directly on the grid itself prior to the 2nd DataBind() call.

I found the property thanks to a bit of trial & error, so maybe it might be worth adding some info. on it in relation to the "LivePersistence" (false) area of your already excellent documentation? Or perhaps even consider making it a public property within the Datasource control?

Just a thought anyway, thanks alot for your help Walaa.

Jamanga
User
Posts: 93
Joined: 21-Jul-2006
# Posted on: 19-Nov-2008 09:43:29   

My apologies re: doco, I just saw it - bloody hell. Sorry I don't know how I missed it before. Thanks guys.

Refetch To ensure fresh data from the database. is retrieved, a flag on the LLBLGenProDataSourceControl2 called Refetch can be set to true, so the DefaultView will refetch the data, even if for example the page number is the same. This can be necessary if the code-behind code decides the data represented by the LLBLGenProDataSource2 control is invalidated and has to be refetched from the database.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Nov-2008 09:55:34   

No prob. simple_smile