Janus Gridex more help needed

Posts   
 
    
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 19-Feb-2005 18:21:42   

I seem to have lost the plot a bit as I am trying to do some tests getting Janus Grid EX to work with EntityCollections but am struggling to display anything. Have been using datasets up until now but it is time to move over.

I have an EntityCollection that is populated with data ( I have checked this and it is definantely populated)

When I bind my entity collection to the standard .NET datagrid it all displays perfectly, however when I drop a Janus datagrid on the form and bind that to the collection i get nothing..... I have created a root table but still no data.... what am I doing wrong?

Im sure there is something simple that I am missing here.

Second question is that when I get this to work I want to only add columns for some of the entity properties not all of them. I can add a column in code that is fine however how do I bind that column to a particular "column" in the entity collection. E.g. If the collections was populated with UserEntity items and I wanted to add a column of UserEntity.Name how can I do this?

Any bits of sample code would be greatly appreciated - many thanks in advance....

I am sorry to be asking so many questions on this but I use grids alot in my applications and need to know that I can do everything that I need to with them using LLBL before I select the best way forward on a large scale build that I am about to do.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Feb-2005 18:54:05   

Have you tried the design time databinding support to set this up? It will solve many of the problems I think.

Just displaying all fields in a janusgrid: after DataSource = collection; do grid.RetrieveStructure(true);

Frans Bouma | Lead developer LLBLGen Pro
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 19-Feb-2005 19:25:48   

Thanks the retreive structure makes the grid show everything, so atleast I can now populate the grid.

However what I really want to be able to do is do what I did when using datasets as the datasource to a grid, in that

I had a grid user control that had various methods that would add columns to the grid such as

public void CTLAddTextColumn (string Caption, string DataMember, int Width, bool Visible)
        {
            Janus.Windows.GridEX.GridEXColumn myCol = new Janus.Windows.GridEX.GridEXColumn();

            try
            {
                myCol.Caption = Caption;
                myCol.Width = Width;
                myCol.Visible = Visible;
                myCol.DataMember = DataMember;
                myCol.Key = DataMember;
                myCol.ColumnType = Janus.Windows.GridEX.ColumnType.Text;
                myCol.EditType = Janus.Windows.GridEX.EditType.NoEdit;
        
                this.RootTable.Columns.Add(myCol);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to add text column - " + ex.Message);
            }
        }

where Caption would be the caption for the column and DataMember was the name of the column in the dataset. I would then just drop the control onto a form and in the form's load event I would set up the columns by writing one line of code for each column I wanted. I would then bing the form to a dataset (that contains each of the DataMembers required)

I would like to continue to use this approad but with collections as the datasource not a dataset.

Is this possible with collections?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Feb-2005 12:55:19   

That should be possible. The only problem is that the grid has to know to which control to bind, i.e. in Adapter you have to specify "" as the datamember for the roottable, in selfservicing you have to specify teh collectionname for the datamember for the roottable. I haven't tested this in code for the janus grid, but it should work. If nothing shows up, it's likely a name thing in the datamember of the roottable.

Frans Bouma | Lead developer LLBLGen Pro
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 21-Feb-2005 13:47:04   

Sorry Otis, dont know what I was doing the other day but it all works fine (with no alteration to my code)

Goodbye datasets.... roll on collections!!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 21-Feb-2005 15:17:08   

OK! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
hplloyd
User
Posts: 191
Joined: 29-Oct-2004
# Posted on: 22-Feb-2005 15:09:44   

Sorry just one minor question now that everyhting is working beautifully.

I am loading data into a collection and displaying this in a grid. When I make changes to the data I save the changes back to the database and as if by magic the collection and hence grid are updated without me having to repopulate the collection from the database - excellent.

However, what if someone else has made changes to the underlying data in my grid - will I see those changes too? ( I assume not) How can I get the collection to periodically check the database for any changes OTHER users have made?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Feb-2005 15:36:43   

hplloyd wrote:

Sorry just one minor question now that everyhting is working beautifully.

I am loading data into a collection and displaying this in a grid. When I make changes to the data I save the changes back to the database and as if by magic the collection and hence grid are updated without me having to repopulate the collection from the database - excellent.

However, what if someone else has made changes to the underlying data in my grid - will I see those changes too? ( I assume not) How can I get the collection to periodically check the database for any changes OTHER users have made?

If they alter the same entity objects (so you pass on the same collection), then you'll see those changes too. If they work on another desktop box and the same database, you won't see those changes until you refetch the entities. I think if you want to see them periodically, set a timer and refetch the entity collection.

Frans Bouma | Lead developer LLBLGen Pro