This is a migrated thread and some comments may be shown as answers.

[Solved] set cell value

3 Answers 225 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ozgur
Top achievements
Rank 1
Ozgur asked on 20 Jul 2009, 08:10 AM
Hi,

 

To edit a row that the user double-click the first cell and enter the desired value, I want to set a different value to the second cell. However, there is a problem in the code below. the second cell value is old value when the user press the TAB key and focus the second cell. The second cell is new value when the user again press the TAB key,  But it is working properly use third cell.

Thanks.



 

private void grdMaliyetHesapla_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)  
 
{  
 
    if (e.Cell.Column.UniqueName == "cPozNo")  
 
        {  
 
            client.PozGetirCompleted += client_PozGetirCompleted;  
 
            client.PozGetirAsync(e.Cell.Value.ToString());  
 
        }  
 
}  
 
void client_PozGetirCompleted(object sender, MaliyetHesapla_S2.MaliyetHesaplaProxy.PozGetirCompletedEventArgs e)  
 
{  
 
    if (e.Result == null || e.Result.Count==0)  
 
        {  
 
            RadWindow.Alert(new DialogParameters() { Header = "Uyar", Content = "Poz bulunamad!", OkButtonContent = "Tamam" });  
 
            return;  
 
        }  
 
 
        GridViewRow currentRow = grdMaliyetHesapla.ItemsControl.ItemsGenerator.ContainerFromItem(grdMaliyetHesapla.CurrentRecord) as GridViewRow;  
 
        foreach (var detail in e.Result)  
 
        {  
 
            GridViewCell cell = currentRow.Items[3] as GridViewCell;   
            if (cell != null)  
 
            {  
 
                cell.Content = detail.cAciklama;  
 
                cell.Value = detail.cAciklama;  
 
            }  
 
        }  
 
}  
 

3 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 20 Jul 2009, 03:09 PM

Hi Ozgur,

I would recommend you to try setting the value of the underlying business object directly , instead of setting the cell value and content.

When you change the value of the bound business object, the RadGridView will automatically update the cell content and value. Of course this will work only if your business object implements correctly the INotifyPropertyChanged interface.

If this does not fit to your scenario, just let me know , so we can thing of another workaround.

Greetings,

Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Ozgur
Top achievements
Rank 1
answered on 21 Jul 2009, 02:54 PM

Hi Pavel,

First of all I would like to thank you for your interest


I would like to do this,


User will enter the order by using the grid. When user enters the product code on the grid the name of the product and price will appear on the 2. And 3. columns. When user enters the quantity the price will be calculated.

 

As a result of that I would like to have the products to be added or organized quickly and enter the orders.

 

Thanks,

0
Pavel Pavlov
Telerik team
answered on 24 Jul 2009, 02:49 PM
Hello Ozgur,

Please see the attached example . It partially resembles your scenario.
When you enter the product code in column 1 , the value in the second cell automatically updates.
The same approach may be used to fill calculated cells such as price or total.
Let me know if you need further assistance adapting this approach  to your project.

Best wishes,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Ozgur
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Ozgur
Top achievements
Rank 1
Share this question
or