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

Change the value of a cell in RadGridView

2 Answers 486 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 10 Dec 2012, 10:16 PM
I am trying to change the value of a cell in my grid

The xaml is as follows:

<telerik:RadGridView AutoGenerateColumns="False" Margin="12,0,12,12" Name="radGridViewNeedsShipping" SelectionMode="Extended" ShowGroupPanel="False" Height="190" VerticalAlignment="Bottom" MouseDoubleClick="rgvOpenTicket">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="PO Number" IsReadOnly="True" UniqueName="SerialNumber" />
                <telerik:GridViewDataColumn Header="Customer" IsReadOnly="True" UniqueName="Customer.EntityName" />
                <telerik:GridViewDataColumn Header="Ship By Date" IsReadOnly="True" UniqueName="TransactionDate" DataFormatString="{}{0:MM/dd/yyyy}"/>
                <telerik:GridViewDataColumn Header="Type" IsReadOnly="True" UniqueName="TransactionTypeId"  />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>


The code to populate the grid is:

private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            
            radGridViewNeedsShipping.ItemsSource = InControlDataAccess.getTransactions(0).Where(i => (i.TransactionTypeId == 11 || i.TransactionTypeId == 12) && (i.HasBeenShipped == null || i.HasBeenShipped == false) && i.InProgress != null && i.InProgress != false).OrderBy(i => i.Id);
           
        }



The TransactionTypeId will be either 11 or 12,

      If TransactionTypeId == 11, then I want to display "Rental" in the Type field

      if TransactionTypeId == 12 then  I want to display "Sales" in the Type field

Also, I want the row to be background color red if TransactionTypeId = 11, and I want the row to be yellow if TransactionTypeId = 12

What would be the best way that I could accomplish this?

2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 11 Dec 2012, 03:05 PM
Hello Craig,

The desired behavior can be quite easily achieved by using BindingConverters and CellStyleSelectors
Will this work in your case? 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Craig
Top achievements
Rank 1
answered on 11 Dec 2012, 06:36 PM
Yes, it worked great. 
Thanks!
Tags
GridView
Asked by
Craig
Top achievements
Rank 1
Answers by
Nick
Telerik team
Craig
Top achievements
Rank 1
Share this question
or