UltraWebGrid example

Posts   
 
    
Posts: 26
Joined: 23-May-2005
# Posted on: 30-Aug-2006 21:16:26   

Does anyone have a quick example how to create a Infragistics Webgrid with a collection, thats shows some columns. I noticed several discussions but could not get a working example.

As I understood from these threads the only way is the GetMultiAsDataTable, but i'm not able to get this running.

Thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 31-Aug-2006 08:07:01   

Please show what you have already tried, and explain what went wrong.

Thanks

Posts: 1251
Joined: 10-Mar-2006
# Posted on: 31-Aug-2006 19:55:42   

It does work, I use it.

Posts: 26
Joined: 23-May-2005
# Posted on: 31-Aug-2006 21:12:18   

This is my code

I get "No Data To Display" on my page, so I guess something is mssing to bind the collection


Dim WithEvents webGrid As UltraWebGrid Dim WithEvents band As New UltraGridBand Dim WithEvents objDs As New ObjectDataSource

: :

  WebGrid = New UltraWebGrid
  GridPlaceHolder.Controls.Add(WebGrid)
  WebGrid.Bands.Add(band)

  band.AddNewRow.View = AddNewRowView.NotSet
  band.AddNewRow.Visible = AddNewRowVisible.NotSet
  band.FilterOptions.AllowRowFiltering = RowFiltering.No
  band.FilterOptions.EmptyString = ""
  band.FilterOptions.FilterDropDownStyle.BackColor = Drawing.Color.White
  band.FilterOptions.FilterDropDownStyle.BorderColor = Drawing.Color.Silver
  band.FilterOptions.FilterDropDownStyle.BorderStyle = Web.UI.WebControls.BorderStyle.Solid
  band.FilterOptions.FilterDropDownStyle.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1)
  band.FilterOptions.FilterDropDownStyle.Font.Names = New String() {"Verdana", "Arial", "Helvetica", "sans-serif"}
  band.FilterOptions.FilterDropDownStyle.Font.Size = System.Web.UI.WebControls.FontUnit.Point(11)
  band.FilterOptions.FilterDropDownStyle.Width = System.Web.UI.WebControls.Unit.Pixel(200)


  band.FilterOptions.FilterDropDownStyle.BorderColor = Drawing.Color.Silver

    For Each Field As CheetahField In Me.DataColumns
      Dim boundColumn As New UltraGridColumn
      boundColumn.BaseColumnName = Field.Name
      boundColumn.Header.Caption = Field.Label
      boundColumn.IsBound = True
      boundColumn.HeaderText = Field.Label
      boundColumn.HeaderStyle.HorizontalAlign = Web.UI.WebControls.HorizontalAlign.Left

      band.Columns.Add(boundColumn)
    Next

: :

  objDs.SelectMethod = "GetMultiAsDataTable"
  objDs.TypeName = "myDAL.CollectionClasses.ClubCollection"
  objDs.SelectParameters.Add(New System.Web.UI.WebControls.Parameter("selectFilter", TypeCode.Object, Nothing))
  objDs.SelectParameters.Add(New System.Web.UI.WebControls.Parameter("maxNumberOfItemsToReturn", TypeCode.UInt64, "0"))
  objDs.SelectParameters.Add(New System.Web.UI.WebControls.Parameter("sortClauses", TypeCode.Object, Nothing))


  webGrid.DataSource = objDs
  'webGrid.DisplayLayout.ExpandableDefault = Expandable.No
  webGrid.DataBind()
Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 01-Sep-2006 15:25:51   

Have you tried using LLBLGenProDataSource(2) rather than the ObjectdataSource?

Posts: 26
Joined: 23-May-2005
# Posted on: 01-Sep-2006 15:49:53   

No, but i'm going to!

This tool has just so many features. sunglasses

Posts: 1251
Joined: 10-Mar-2006
# Posted on: 01-Sep-2006 15:52:51   

use LLBLGenProDataSource and your life will be much easier.

Also, get one working using the designer and generated code, then you can make sure your code is right...

Posts: 26
Joined: 23-May-2005
# Posted on: 01-Sep-2006 16:41:32   

Same result here: "No Data To "Display"

I must overlooking something... and there are records.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 01-Sep-2006 19:24:26   

When you enable tracing, are there any queries generated ? ( DQE tracing, see troubleshooting and debugging in manual)

You shouldn't have to setup the binding manually, simply define the datasource in the html and set it as the datasource of the grid.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 26
Joined: 23-May-2005
# Posted on: 01-Sep-2006 20:39:54   

In the designer there'e no problem., everything works Ok. In my program i would like to this this dynamically. I'v the tracing below but cannot see what's wrong. Hope someone sees what I'm doing wrong

Dim WithEvents webGrid As UltraWebGrid Dim WithEvents band As UltraGridBand Dim WithEvents llobjDs As SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource Dim WithEvents boundColumn As UltraGridColumn

webGrid = New UltraWebGrid
Me.Form.Controls.Add(webGrid)

llobjDs = New SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource

llobjDs.CacheLocation = DataSourceCacheLocation.Session
llobjDs.DataContainerType = DataSourceDataContainerType.EntityCollection
llobjDs.EnablePaging = True
llobjDs.LivePersistence = True
llobjDs.EntityCollectionTypeName = "Cheetah.NET.DAL.CollectionClasses.ClubCollection, EricaDAL"

webGrid.DataSourceID = llobjDs.ID

band = New UltraGridBand
band.Key = "Band 0"
band.AddNewRow.Visible = AddNewRowVisible.NotSet
band.AddNewRow.View = AddNewRowView.NotSet
band.FilterOptions.AllString = ""
band.FilterOptions.EmptyString = ""
band.FilterOptions.NonEmptyString = ""
band.FilterOptions.FilterDropDownStyle.BackColor = Drawing.Color.White
band.FilterOptions.FilterDropDownStyle.BorderColor = Drawing.Color.Silver
band.FilterOptions.FilterDropDownStyle.BorderStyle = BorderStyle.Solid
band.FilterOptions.FilterDropDownStyle.BorderWidth = Unit.Pixel(1)
band.FilterOptions.FilterDropDownStyle.CustomRules = "overflow:auto;"
band.FilterOptions.FilterDropDownStyle.Font.Names = New String() {"Verdana,Arial,Helvetica,sans-serif"}
band.FilterOptions.FilterDropDownStyle.Font.Size = FontUnit.Point(11)
band.FilterOptions.FilterDropDownStyle.Width = Unit.Pixel(200)
band.FilterOptions.FilterDropDownStyle.Padding.Left = Unit.Pixel(2)
band.FilterOptions.FilterHighlightRowStyle.ForeColor = Drawing.Color.White

boundColumn = New UltraGridColumn
boundColumn.BaseColumnName = "clubId"
boundColumn.IsBound = True
boundColumn.Header.Caption = "Id"
band.Columns.Add(boundColumn)

boundColumn = New UltraGridColumn
boundColumn.BaseColumnName = "Name"
boundColumn.IsBound = True
boundColumn.Header.Caption = "Naam"
band.Columns.Add(boundColumn)

webGrid.DataBind()

-tracing Method Enter: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.FetchPrefetchPath Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.FetchPrefetchPath Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.FetchPrefetchPath Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.FetchPrefetchPath Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.FetchPrefetchPath Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformGetMultiAction Method Enter: CreatePagingSelectDQ Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Generated Sql query: Query: SELECT [Erica].[dbo].[Event].[EventId], [Erica].[dbo].[Event].[ClubId], [Erica].[dbo].[Event].[IsMatch], [Erica].[dbo].[Event].[IsHomeMatch], [Erica].[dbo].[Event].[CompetitionId], [Erica].[dbo].[Event].[HomeTeamId], [Erica].[dbo].[Event].[VisitorsTeamId], [Erica].[dbo].[Event].[LocationId], [Erica].[dbo].[Event].[StartTime], [Erica].[dbo].[Event].[EndTime], [Erica].[dbo].[Event].[IsWholeDay], [Erica].[dbo].[Event].[Description], [Erica].[dbo].[Event].[ShortDescription], [Erica].[dbo].[Event].[MatchId], [Erica].[dbo].[Event].[RecurrenceId], [Erica].[dbo].[Event].[IsClosed], [Erica].[dbo].[Event].[Created], [Erica].[dbo].[Event].[CreatedById] FROM [Erica].[dbo].[Event]

Method Exit: CreateSelectDQ Method Exit: CreatePagingSelectDQ: no paging. Method Enter: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.ExecuteMultiRowRetrievalQuery Method Exit: DaoBase.PerformGetMultiAction Method Enter: DaoBase.PerformFetchEntityAction Method Enter: CreateSelectDQ Method Enter: CreateSelectDQ Generated Sql query: Query: SELECT [Erica].[dbo].[Location].[LocationId], [Erica].[dbo].[Location].[Name], [Erica].[dbo].[Location].[RouteDescription], [Erica].[dbo].[Location].[IsActive], [Erica].[dbo].[Location].[VisitAddressId], [Erica].[dbo].[Location].[PhoneNumber], [Erica].[dbo].[Location].[Email], [Erica].[dbo].[Location].[Url]FROM [Erica].[dbo].[Location] WHERE ( [Erica].[dbo].[Location].[LocationId] = @LocationId1) Parameter: @LocationId1 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 1.

Method Exit: CreateSelectDQ Method Enter: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.ExecuteSingleRowRetrievalQuery Method Exit: DaoBase.PerformFetchEntityAction

Posts: 26
Joined: 23-May-2005
# Posted on: 01-Sep-2006 22:20:41   

I'm one step further. If i define the datasource via webGrid.DataSourceID = LLBLGenProDataSource1.ID where LLBLGenProDataSource1 is the datasource placed on the form by the designer everything is ok

so what's the difference between:

in asp

<cc1:LLBLGenProDataSource ID="LLBLGenProDataSource1" runat="server" DataContainerType="EntityCollection" EntityCollectionTypeName="Cheetah.NET.DAL.CollectionClasses.ClubCollection, EricaDAL"> </cc1:LLBLGenProDataSource>

and in vb

llobjDs = New SD.LLBLGen.Pro.ORMSupportClasses.LLBLGenProDataSource Me.Form.Controls.Add(llobjDs)

llobjDs.CacheLocation = DataSourceCacheLocation.Session
llobjDs.DataContainerType = DataSourceDataContainerType.EntityCollection
llobjDs.EntityCollectionTypeName = "Cheetah.NET.DAL.CollectionClasses.ClubCollection, EricaDAL"
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 03-Sep-2006 10:14:35   

I think the timing when the datasource is bound to the grid. WHen an asp.net page is loaded and rendered, it goes through several phases (I personally find that a very bad design, but what can we do about it?) and in each phase other things happen. This means that if you bind the datasource too late, the grid won't request data from the datasource when it should.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 26
Joined: 23-May-2005
# Posted on: 03-Sep-2006 13:06:48   

So does this mean there is nothing i can do about it. I'm afraid i don't understand where to put this. I've tried page_init, page_load but none of these work. i guess i'm stuck with the stand MS webgrid.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39588
Joined: 17-Aug-2003
# Posted on: 03-Sep-2006 15:30:01   

John wrote:

So does this mean there is nothing i can do about it. I'm afraid i don't understand where to put this. I've tried page_init, page_load but none of these work. i guess i'm stuck with the stand MS webgrid.

Perhaps I missed something important, but why don't you specify the datasource in the html declaratively?

Frans Bouma | Lead developer LLBLGen Pro
Posts: 26
Joined: 23-May-2005
# Posted on: 04-Sep-2006 15:16:22   

Thanks for your interest!

We use a general program to build our page dynamically.

BTW: if i set the autogenerate=false I get the same error.

So i'm still puzzeled about it. Is the UltraWebgrid malfunctioning, Am i doing something wrong. Why are there no problems with the MS webgrid.

Should i discus this with Infragistics or is there something to be enhanced in the llblgen datasource?

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 05-Sep-2006 07:01:16   

So i'm still puzzeled about it. Is the UltraWebgrid malfunctioning, Am i doing something wrong. Why are there no problems with the MS webgrid.

Should i discus this with Infragistics or is there something to be enhanced in the llblgen datasource?

If things are working with the MS Grid and not with the UltraWebgrid, then I suggest you should discuss this with Infragistics.

Posts: 26
Joined: 23-May-2005
# Posted on: 08-Sep-2006 21:59:19   

FYI:

De problem was solved. Eventually the posicition of adding the control to the form was moved after the column definition. Somehow the control isn't realised as it should when the control is added before the definition. It wasn't a llgblen datasource problemwink