We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Drop grid in a GridDataboundGrid

Thread ID:

Created:

Updated:

Platform:

Replies:

60195 Apr 30,2007 10:19 AM May 4,2007 11:40 AM Windows Forms 10
loading
Tags: GridControl
Dan Garvin
Asked On April 30, 2007 10:19 AM

In one column of a gdbg I want to drop a grid (another gdbg) that itself has a combobox and a GridListControl. I'm having trouble following the examples. Problem is when I try and set the column properies using the binder, as I'm used to doing with gdbg's. The binder is null. Am I using the correct approach? Here is the basic code:

In the main gdbg, I instantiate the child grid and attach it to one of the colums...

// Create child grid
gridPharm = new GridDataBoundGrid();
gridPharm.ThemesEnabled = true;
gridPharm.CausesValidation = false;
DropDownGridCellModel aModel = new DropDownGridCellModel(gridDx.Model);
gridDx.Model.CellModels.Add("GridPharmDropCell", aModel);
aModel.EmbeddedGrid = gridPharm;
aModel.SupportsChoiceList = true;
...
gbc = binder.InternalColumns["Pharmacologic Plan"];
gbc.StyleInfo.CellType = "GridPharmDropCell";


In the main grid ShowingDropDown event, I populate and format the drop grid (I want to make one of the columns a combobox and another a GridListControl...

gridPharm.DataSource = dtPharm;
GridModelDataBinder binder = gridPharm.Binder;
gridPharm.Binder.SuspendBinding();

gridPharm.AllowResizeToFit = false;
gridPharm.TableStyle.Trimming = StringTrimming.EllipsisWord;
gridPharm.Model.BaseStylesMap["Row Header"].StyleInfo.CellType = "Header";
GridBoundColumn gbc;

//id
gridPharm.Model.HideCols["id"] = true;
//visitId
gridPharm.Model.HideCols["visitId"] = true;
//patientId
gridPharm.Model.HideCols["patientId"] = true;
//visitDxId
gridPharm.Model.HideCols["visitDxId"] = true;
//Drug name
gbc = binder.InternalColumns["Drug Name"];
gbc.StyleInfo.CellType = "GridListControl";
...

The code fails on gbc.styleInfo.celltype = because gbc is null. Any ideas? Thanks.

haneefm [Syncfusion]
Replied On April 30, 2007 03:03 PM

Hi Dan,

Thank you for your update.

Is it possible for you to upload us a minimal sample to reproduce the issue here? This will help us to analyse the issue further.

Best regards,
Haneef

Dan Garvin
Replied On May 2, 2007 02:25 PM

I've attached an application that shows the problem. It took some time to create a standalone app that didn't require the database. So, to run this, you'll need to change the form1.cs code that calls the xml files (see instances of .ReadXMLSchema and .ReadXML. Change the paths to match where you installed the application and then run it. You'll see a grid. Drop down the last column to the right and you should see the error. The error is caused because the attempt to create the renderer produced a null object. Thanks for your help.

Test_DropGrid1.zip

haneefm [Syncfusion]
Replied On May 2, 2007 03:57 PM

Hi Dan,

You can try setting the parent control of dropdown DataBoundGrid("gridPharm") control to a gridDx in LoadGridDx method . Please try the below code snippet and let me know if this helps.

//LoadGridDx method.
DropDownGridCellModel aModel = new DropDownGridCellModel(gridDx.Model);
gridDx.Model.CellModels.Add("GridPharmDropCell", aModel);
aModel.EmbeddedGrid = gridPharm;
gridDx.Controls.Add(gridPharm);
aModel.SupportsChoiceList = true;

Here is a modified sample.
ModifiedTest_DropGrid1.zip

Best regards,
Haneef

Dan Garvin
Replied On May 2, 2007 09:06 PM

Excellent. That worked. I set the gridPharm.Visible = false when the grid was added and then visible = true when displayed so that it is not seen until the drop down. Plesae see attached.

I've taken a couple more steps and have some followup questions, if you please.

1. How do I control the left location and width of the entire drop down control (as you see the right side of the grid is not showing).

2. How do I control the width of the columns in the drop down grid.

3. Can the dropdown grid columns be sorted?

4. Once the grid is dropped down, pressing the drop down button again closes it. Can I add a close button to the control?

5. Please notice that the dropdown grid now has a drop down grid list control with two columns (drug name and class). This is the same approach as the drop down grid list on the parent grid (Common diagnosis column on gridDx). How can I allow the users to sort the columns of the GridDropDownGridList?

Thank you very much.
-dan

Modified_Rev2_Test_DropGrid1.zip

Dan Garvin
Replied On May 2, 2007 09:23 PM

Forgot to ask about a flicker. When the dropdown button in gridDx (the parent grid) is pressed, you can just see the drop grid and then nothing. You have to press the dropdown button again to see the grid. For some reason, the gridDx_CurrentCellCloseDropDown event is being fired the first time the drop grid is opened. How can this be avoided? Thanks for your help.

Dan Garvin
Replied On May 3, 2007 03:22 PM

The only issue I'm still struggling with is the CloseDropDown event is fired the first time I drop down the grid drop down. I found that the this occurs when the datasource is set:

gridPharm.DataSource = dtPharm;

Any idea why this would be and how I can avoid making the user click twice on the dropdown button the first time the grid is displayed? Thanks.
-dan

haneefm [Syncfusion]
Replied On May 3, 2007 05:28 PM

Hi Dan,

1)How do I control the left location and width of the entire drop down control (as you see the right side of the grid is not showing).
>>>>
If you want to change the width of the DropDown in a GridDropDownl Cell, then you have to handle the CurrentCellShowingDropDown event, and set e.Size there. (Only the width is applicable in a GridListControl celltype, the height is determined by the DropDownRows parameter. Here is a code snippet to show this.

DropDownGridCellRenderer cr = gridDx.CurrentCell.Renderer as DropDownGridCellRenderer;
if (cr != null)
{
DropDownGridCellModel model = cr.StyleInfo.CellModel as DropDownGridCellModel;
if (model != null)
{
GridDataBoundGrid grid = model.EmbeddedGrid as GridDataBoundGrid;
if (grid != null)
{
int width = grid.Model.ColWidths.GetTotal(0, grid.Model.ColCount);
int hegiht = grid.Model.RowHeights.GetTotal(0, grid.Model.RowCount);
e.Size = new Size(width, hegiht);
}
}
}

2. How do I control the width of the columns in the drop down grid.
>>>
You can use the below code snippet to set the column width of the DropDown grid.

DropDownGridCellModel model = cr.StyleInfo.CellModel as DropDownGridCellModel;
if (model != null)
{
GridDataBoundGrid grid = model.EmbeddedGrid as GridDataBoundGrid;
if (grid != null)
{
grid.Model.ColWidths["Drug Name"] = 10;
}
}


3 & 5) Can the dropdown grid columns be sorted?
>>>>>
You can use the SortColumn method to sort the required column in a grid.
DropDownGridCellModel model = cr.StyleInfo.CellModel as DropDownGridCellModel;
if (model != null)
{
GridDataBoundGrid grid = model.EmbeddedGrid as GridDataBoundGrid;
if (grid != null)
{
grid.SortColumn(i);
}
}

4)Once the grid is dropped down, pressing the drop down button again closes it. Can I add a close button to the control?
>>>>>
You can create custom celltype, it requires a model class and a renderer class. The model class handles the serialization requirements for the control and creates the renderer class. The renderer class handles the UI requirements of the cell. This sample in \Syncfusion\Essential Studio\4.1.0.10\windows\Grid.Windows\Samples\In Depth\DerivedCellControlTutorial can be referred.

Please look at the sample for more detail
GridListEditSample.zip

Best regards,
Haneef

Dan Garvin
Replied On May 3, 2007 06:40 PM

Thanks Haneef. Any ideas on the firing of the CurrentCellCloseDropDown event when the datasource is set?
-dan

haneefm [Syncfusion]
Replied On May 4, 2007 10:55 AM


Dan Garvin
Replied On May 4, 2007 11:40 AM

Thanks for your help, Haneef.
-dan

>Hi Dan,

Please refer this.
http://www.syncfusion.com/support/forums/message.aspx?&MessageID=60405

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;