ListControlPart and FilterBar
I'm using GDBG.
I have a drop down cell with custom model and renderer, that displays a ListControlPart while arranging the columns.
I would like to provide a filter bar in the grid that shows up when the drop down is opened, but the WireGrid function in GridFilterBar only take GridDataBoundGrid, and not GridControl, which is what I get from the ListControlPart.Grid.
Is there a way to do something like this?
Alternatively, when opening the drop down list, using the AutoComplete style, I can type in the grid cell, and have the drop down list automatically jump to the matching value. My problem is that when choosing the row, the value in the cell is the valueMember.
I'd like to be able to insert a different value in the grid cell, specifically the displayMember. For example, I have a list of banks, with their code and name. If I set the name to be the value member, then the grid cell will search and display the bank name, but I want it to display the bank code instead.
Any way to do that ?
I have a drop down cell with custom model and renderer, that displays a ListControlPart while arranging the columns.
I would like to provide a filter bar in the grid that shows up when the drop down is opened, but the WireGrid function in GridFilterBar only take GridDataBoundGrid, and not GridControl, which is what I get from the ListControlPart.Grid.
Is there a way to do something like this?
Alternatively, when opening the drop down list, using the AutoComplete style, I can type in the grid cell, and have the drop down list automatically jump to the matching value. My problem is that when choosing the row, the value in the cell is the valueMember.
I'd like to be able to insert a different value in the grid cell, specifically the displayMember. For example, I have a list of banks, with their code and name. If I set the name to be the value member, then the grid cell will search and display the bank name, but I want it to display the bank code instead.
Any way to do that ?
SIGN IN To post a reply.
4 Replies
HA
haneefm
Syncfusion Team
May 31, 2007 12:14 AM UTC
Hi Miki,
One way you can do this by deriving the GridComboBoxCellRenderer and override the GetDisplayText to set your display text .Here is a code snippet
public class MyComboBoxCellModel : GridComboBoxCellModel
{
public MyComboBoxCellModel(GridModel grid): base(grid)
{}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{
return new MyComboBoxCellRenderer(control, this);
}
}
public class MyComboBoxCellRenderer : GridComboBoxCellRenderer
{
public MyComboBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel): base(grid, cellModel)
{
this.SupportsFocusControl = false;
}
public override string GetDisplayText()
{
return "YourTextHere";
}
}
Best regards,
Haneef
One way you can do this by deriving the GridComboBoxCellRenderer and override the GetDisplayText to set your display text .Here is a code snippet
public class MyComboBoxCellModel : GridComboBoxCellModel
{
public MyComboBoxCellModel(GridModel grid): base(grid)
{}
public override GridCellRendererBase CreateRenderer(GridControlBase control)
{
return new MyComboBoxCellRenderer(control, this);
}
}
public class MyComboBoxCellRenderer : GridComboBoxCellRenderer
{
public MyComboBoxCellRenderer(GridControlBase grid, GridCellModelBase cellModel): base(grid, cellModel)
{
this.SupportsFocusControl = false;
}
public override string GetDisplayText()
{
return "YourTextHere";
}
}
Best regards,
Haneef
MW
Miki Watts
May 31, 2007 08:22 AM UTC
I should have mentioned that I'm deriving the renderer from GridDropDownGridListControlCellRenderer, as I need to also customize the display of the popup grid.
GetDisplayText wasn't called at all, but OnSetControlText was, and I was able to give it different text to display in the parent grid cell, but when leaving the grid cell, it just cleared.
GetDisplayText wasn't called at all, but OnSetControlText was, and I was able to give it different text to display in the parent grid cell, but when leaving the grid cell, it just cleared.
HA
haneefm
Syncfusion Team
May 31, 2007 09:15 PM UTC
Hi Miki,
Issue 1: change the grid settings
If you want to change the GridListControl settings in a custom grid cell then you need to override the CreateListControlPart method and retrun your own grid list control. Here is a code snippet
protected override GridListControl CreateListControlPart()
{
GridListControl grid = new GridListControl();
grid.Grid.Model.Options.AlphaBlendSelectionColor = Color.Red;
return grid;
}
If you want to modify the DropDown datasource in a grid cell then you need to handle the CurrentCellShowingDropDown event and set the ListControlPart.DataSource to new datasource.
Issue 2: Keep the text in a grid cell.
One way you can do this by setting the style.Text in onSetControlText event. Below is a code snippet.
protected override void OnSetControlText(string text)
{
if( text == "parentName5" || text == "parentName4" )
{
int index = base.FindItem(text,false,0,true);
this.TextBox.Text = "Selected Index " + Convert.ToString(index);
this.Grid.Model[RowIndex,ColIndex].Text = this.TextBox.Text;
}
else
base.OnSetControlText(text);
}
Here is a sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F61668/main.htm
Best regards,
Haneef
Issue 1: change the grid settings
If you want to change the GridListControl settings in a custom grid cell then you need to override the CreateListControlPart method and retrun your own grid list control. Here is a code snippet
protected override GridListControl CreateListControlPart()
{
GridListControl grid = new GridListControl();
grid.Grid.Model.Options.AlphaBlendSelectionColor = Color.Red;
return grid;
}
If you want to modify the DropDown datasource in a grid cell then you need to handle the CurrentCellShowingDropDown event and set the ListControlPart.DataSource to new datasource.
Issue 2: Keep the text in a grid cell.
One way you can do this by setting the style.Text in onSetControlText event. Below is a code snippet.
protected override void OnSetControlText(string text)
{
if( text == "parentName5" || text == "parentName4" )
{
int index = base.FindItem(text,false,0,true);
this.TextBox.Text = "Selected Index " + Convert.ToString(index);
this.Grid.Model[RowIndex,ColIndex].Text = this.TextBox.Text;
}
else
base.OnSetControlText(text);
}
Here is a sample for implementation.
http://websamples.syncfusion.com/samples/Grid.Windows/F61668/main.htm
Best regards,
Haneef
MW
Miki Watts
June 4, 2007 05:14 PM UTC
Thanks Haneef, the OnSetControlText did it.
Only one problem now, if I select the row using the dropdown, it works just fine and I see the bank code instead of the bank name in the grid cell.
However, if I type the bank name into the grid cell,I still see the bank name in the grid, and when moving around with the keyboard arrows, the bank name changes to the bank code and back whenever i pass over the grid cell.
I need the behaviour to be consistent and act like in the first case I described.
Only one problem now, if I select the row using the dropdown, it works just fine and I see the bank code instead of the bank name in the grid cell.
However, if I type the bank name into the grid cell,I still see the bank name in the grid, and when moving around with the keyboard arrows, the bank name changes to the bank code and back whenever i pass over the grid cell.
I need the behaviour to be consistent and act like in the first case I described.
SIGN IN To post a reply.
- 4 Replies
- 2 Participants
-
MW Miki Watts
- May 30, 2007 05:58 PM UTC
- Jun 4, 2007 05:14 PM UTC