Need help with Janus asp.net GridEX

Posts   
 
    
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 09-Dec-2004 20:53:52   

I'm trying to make the Janus asp.net GridEX control work in BatchUpdate mode and can't seem to figure out how to make the Janus example code work with LLBLGen entities. Below is the copy of their method that does the cell update that I need to convert to use entities. If any knows how to do this please help.


        private void GridEX1_CellUpdated(object sender, Janus.Web.GridEX.ColumnActionEventArgs e)
        {   
            DataTable table = this.northWind1.Products; 
            Janus.Web.GridEX.GridEXRow gridEXRow = this.GridEX1.GetRow();
            if(gridEXRow.RowType != RowType.NewRecord)
            {               
                DataRow dataRow = table.Rows.Find(gridEXRow.DataKeyValue);          
                if(dataRow != null)
                {
                    dataRow[e.Column.DataMember] = gridEXRow.Cells[e.Column].Value;
                }               
            }
        }

much appreciated,

Aaron

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39898
Joined: 17-Aug-2003
# Posted on: 09-Dec-2004 21:50:08   

So basicly, you want to find an entity back based on the PK?

Frans Bouma | Lead developer LLBLGen Pro
tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 09-Dec-2004 22:53:22   

Otis wrote:

So basicly, you want to find an entity back based on the PK?

Yeah, I think that sounds right. I will have a entity collection which I then to pull a entity out of using the PK. I think I then need to set a property value using the index of the property. The code below now has comments added to it that shows what needs to happen. The two things here that I don't know how to do is get the entity from the collection using the PK and setting the entity property using the property index. Unless I am reading this code wrong I think this is what needs to happen.


        private void GridEX1_CellUpdated(object sender, Janus.Web.GridEX.ColumnActionEventArgs e)
        {   
            DataTable table = this.northWind1.Products;  // Get entity collection
            Janus.Web.GridEX.GridEXRow gridEXRow = this.GridEX1.GetRow();
            if(gridEXRow.RowType != RowType.NewRecord)
            {               
                DataRow dataRow = table.Rows.Find(gridEXRow.DataKeyValue);  // Get entity from collection using PK
                if(dataRow != null)
                {
                    dataRow[e.Column.DataMember] = gridEXRow.Cells[e.Column].Value; // Set value of property using property index
                }               
            }
        }

tprohas
User
Posts: 257
Joined: 23-Mar-2004
# Posted on: 10-Dec-2004 00:01:05   

Just in case anyone else need to do this here is the code that I used. This does still leave a second part to my problem unsolved.

Next I'm going to need to figure out how to save the child tables in my grid. So I still need help with this grid if anyone has experience using it.


        private void gridEX_CellUpdated(object sender, ColumnActionEventArgs e)
        {
            GridEXRow row = this.gridEX.GetRow();
            //row.DataKeyValue // PK
            int position = row.Position - 1;
            if ( row.RowType != RowType.NewRecord )
            {
                this.products[position].SetNewFieldValue( e.Column.Key, row.Cells[e.Column].Value );
            }
        }

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39898
Joined: 17-Aug-2003
# Posted on: 10-Dec-2004 11:22:32   

If it's possible to specify which column is the 'key' column, it probably should work out of the box (but perhaps the grid grabs it from the datatable definition, don't know).

You can also use the IndexOf method using this trick: (I bound a CustomerCollection to the grid) CustomerEntity chops = new CustomerEntity(); chops.CustomerId = "CHOPS"; chops.IsNew = false; int index = customers.IndexOf(chops);

will find the entity with the PK "CHOPS".

Frans Bouma | Lead developer LLBLGen Pro