Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Extending the UltraWebGrid Class
posted

Greetings Infragisticians, 

I've got a ton of web grids that i would like to summarily modify to display with the same paging behavior... i've got it paging every 25 records, however, if there are more than 5 pages (125 records) I would like to programmatically change from a Prev/Next paging StyleMode to a ComboBox, as some of these UltraWebGrids can easily consist of more than 50 pages of data, I figure the behavior would be like this:

                    If uwg_X.Rows.Count > 125 Then
                        uwg_X.DisplayLayout.Pager.StyleMode = PagerStyleMode.ComboBox
                    Else
                        uwg_X.DisplayLayout.Pager.StyleMode = PagerStyleMode.PrevNext
                    End If

However, i would rather not create a "Sub uwg_X_InitializeLayout()" for each of these grids, as there are so many of them...

I thought the easiest way to do this would be to extend the UltraWebGrid class as a custom class and add this code to the Sub New() constructor method, so all of these grids are instantiated with this logic built-in, but I can't find any programmatic examples of this.

I tried creating a new class like this:

Imports Microsoft.VisualBasic
Imports Infragistics.WebUI.UltraWebGrid
Imports Infragistics.WebUI.Design
Imports Infragistics.WebUI.Shared
Imports Infragistics.WebUI.CalcEngine
Imports Infragistics.WebUI.WebControls
Imports Infragistics.WebUI.Util.Serialization



Namespace CustomClasses

    Public Class CustomWebGrid
        Inherits Infragistics.WebUI.UltraWebGrid.UltraWebGrid
        Implements IUltraCalcParticipant, IGetClientSideEvents, IProvideDesignTimeHtml, IProvideAppStyling, & _ 
        IProvideDefaultStyles, IProvideStyleSheet, ISmartCallbackRender, IUltraLicensedComponent, & _ 
        ICanEditNavBar, IPlugInConsumer, IResolveStyles, IXPathDataNavigable, ISupportPresetSerialization, & _ 
        IProvideImageDirectoryResolution

        Public Sub New()
            If Me.Rows.Count > 125 Then
                Me.DisplayLayout.Pager.StyleMode = Infragistics.WebUI.UltraWebGrid.PagerStyleMode.ComboBox
            Else
                Me.DisplayLayout.Pager.StyleMode = Infragistics.WebUI.UltraWebGrid.PagerStyleMode.PrevNext
            End If
        End Sub

    End Class

End Namespace

After this, I put this reference at the top of the ASCX on which I would like to use the new control:
<%@ Register Assembly="CustomWebGrid" Namespace="GESlsOrd" TagPrefix="cust" %>

And then I started changing the tags on an existing UltraWebGrid on the ASCX from <igtbl:UltraWebGrid> ...
to <cust:CustomWebGrid> ...
<Bands>
<cust:UltraGridBand ...>
etc.

but the red-underlines seem to be a clear indication that this is not how it is done...

Can anyone offer suggestions on the correct way to do this?

Thanks much, in advance!

  • 3147
    posted

    It doesn't recognize <cust:UltraGridBand...> because the tag prefix "cust" is registered for namespace GESlsOrd in CustomWebGrid assembly. You should be using "igtbl" prefix for UltraGridBand:

    <cust:CustomWebGrid> ...
        <Bands>
            <igtbl:UltraGridBand ...>
     

    Regards,
    Nick