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

Edit RadGridView

1 Answer 120 Views
GridView
This is a migrated thread and some comments may be shown as answers.
תמרה
Top achievements
Rank 1
תמרה asked on 21 Jun 2015, 02:33 PM

i have a radGrid that bind to string with delimiter such as : string: key=value;key=value;....
i bind this string to the grid by converter from string to dictionary and back.

this is the radgrid:

<telerik:RadGridView x:Name="radGrid" Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="2"
            Margin="10,20,10,10"   NewRowPosition="Top"
            ItemsSource="{Binding CurrentParameter.Values,  Mode=TwoWay,
   Converter={StaticResource StringToDictConverter}}"
            AddingNewDataItem="valuesGrid_AddingNewDataItem"
            CanUserInsertRows="True" IsReadOnly="False"
            CanUserDeleteRows ="True"
            AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                <telerik:GridViewSelectColumn/>
                <telerik:GridViewDataColumn Header="Key"  DataMemberBinding="{Binding Key}" Width="*">
                </telerik:GridViewDataColumn>
              <telerik:GridViewDataColumn Header="Value"    DataMemberBinding="{Binding Value}" Width="*">                                       </telerik:GridViewDataColumn>
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>

this is the converter:

public object Convert(
              object value,
              Type targetType,
              object parameter,
              CultureInfo culture
          )
      {
          Dictionary<string, string> dict = new Dictionary<string, string>();
          if (value != null)
          {
              string[] arr = value.ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
              foreach (string s in arr)
              {
                  string[] sArr = s.Split(new string[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
                  dict.Add(sArr[0], sArr[1]);
              }
          }
          return dict;
           
      }
 
      public object ConvertBack
          (
              object value,
              Type targetType,
              object parameter,
              CultureInfo culture
          )
      {
          if (!(value is Dictionary<string, string>))
              return null;
          string sBack = "";
          foreach (KeyValuePair<string, string> item in (Dictionary<string, string>)value)
          {
              sBack += item.Key + "=" + item.Value + ";";
          }
          return sBack;
      }

the currentParameter Implements INotifyPropertyChanged.

so i want to edit the values in radGrid but it's not possible because the  keyValuePair from converter is read only!

what i can do?

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 24 Jun 2015, 11:50 AM
Hello,

I implemented the code you pasted in a sample project and such error is not raised. Can you please take a look at it and let me know if I am missing something?

Regards,
Stefan X1
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
תמרה
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or