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

GridViewComboBoxColumn

3 Answers 67 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Zerka
Top achievements
Rank 1
Zerka asked on 29 Jun 2011, 09:51 AM

Hi,

In my GridViewComboboxColumn, the display member is string and value is integer. User can do filtering. But the operations shown on this column in the filtering row are for integer instead for string (please see attachment). Can you please tell me how can I solve this?

The second problem is when I copy(either by context menu or ctrl + c) the combobox value, integer value is copying. I want to copy the text value. What is the best way to do? Can I get the display member? My copy/paste code is working fine with other columns. I only have problem with combobox columns.

Thanks

Regards

Zerka

 

3 Answers, 1 is accepted

Sort by
0
Zerka
Top achievements
Rank 1
answered on 01 Jul 2011, 07:54 AM
Hi

I am still looking for the solution. Any help would be appreciated.

Regards

Zerka

0
Svett
Telerik team
answered on 04 Jul 2011, 10:04 AM
Hello Zerka,

Presently, this is a disadvantage of the filtering in GridViewComboBoxColumn. We will improve it in one of the next releases. I confirm that the copy-paste behavior is an issue in the latest release. I added it to our public issue tracking system. It will be addressed in one of the next releases.  In the meantime, you can use the ContextMenuOpening to achieve the desired behavior:

private void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    GridComboBoxCellElement comboBoxCell = e.ContextMenuProvider as GridComboBoxCellElement;
 
    if (comboBoxCell == null)
    {
        return;
    }
 
    string copyID = RadGridLocalizationProvider.CurrentProvider.GetLocalizedString(RadGridStringId.CopyMenuItem);
 
    foreach (RadMenuItem item in e.ContextMenu.Items)
    {
        if (item.Name == copyID)
        {
            item.Click -= new EventHandler(copy_Click);
            item.Click += new EventHandler(copy_Click);
            break;
        }
    }
}
 
private void copy_Click(object sender, EventArgs e)
{
    PropertyInfo propertyInfo = typeof(RadGridViewElement).GetProperty("ClipboardObject",
        BindingFlags.NonPublic | BindingFlags.Instance);
 
    GridViewComboBoxColumn combColumn = this.radGridView1.CurrentColumn as GridViewComboBoxColumn;
    object value = combColumn.GetLookupValue(this.radGridView1.CurrentCell.Value);
    propertyInfo.SetValue(this.radGridView1.GridViewElement, value, null);
 
}

I updated your Telerik points.

Regards,
Svett
the Telerik team
Registration for Q2 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting July 18th and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Zerka
Top achievements
Rank 1
answered on 05 Jul 2011, 12:22 PM
Hi,

Thanks for the help.

Regards

Zerka
Tags
GridView
Asked by
Zerka
Top achievements
Rank 1
Answers by
Zerka
Top achievements
Rank 1
Svett
Telerik team
Share this question
or