Hi,
I am facing a weird problem. I am unable figure out the mistake in my code. Here is my problem:
I've set EditrorControlID of a column in a webgrid to webdatechooser and another column's EditorControlID to a webcombo. Initially, when the page loads, these two controls are getting displayed on the screen (figure 1). How can they be in default hidden state? When the grid actually has data and I clik in the respective cell, then the controls disappear form the initial place where they are displayed. It works fine after that (figure 2).
Another problem as you can see here (figure 3) is that the dropdown values are not getting displayed completely. Here is the markup for that:
<igsch:WebDateChooser ID="DynamicWebDateChooser" runat="server" StyleSetName="Office2007Black" EnableAppStyling="true" StyleSetPath="~/ig_res/"> <ExpandEffects Type="Fade" Opacity="100" ShadowWidth="1" /> <ClientSideEvents AfterCloseUp="StartDateWebDateChooser_AfterCloseUp" /> </igsch:WebDateChooser> <igcmbo:webcombo id="CommentsSignoffCombo" runat="server" Width="165px" Font-Names="Verdana" Font-Size="10pt" Version="4.00" StyleSetName="RubberBlack" EnableAppStyling="true" StyleSetPath="~/ig_res/"> <ExpandEffects ShadowColor="LightGray"></ExpandEffects> <DropDownLayout bordercollapse="Separate" colheadersvisible="No" gridlines="Horizontal" rowheightdefault="20px" DropdownWidth="165px" rowselectors="No" tablelayout="Fixed" DropdownHeight="100px" version="4.00"> <framestyle backcolor="Silver" borderstyle="Ridge" borderwidth="2px" cursor="Default" font-names="Verdana" font-size="10pt" height="100px" width="165px"> </framestyle> <RowStyle BackColor="White" BorderColor="Gray" BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="10pt"> <BorderDetails WidthLeft="0px" WidthTop="0px" /> </RowStyle> </DropDownLayout> </igcmbo:webcombo>
Please help me with this.
Thanks,
Kala
Issue 1 (hide control at load time): You could set Visible="false" to both the controls. It will be displayed automatically when data is populated in it.
Issue 2 (drop down value display): Try setting ColWidthDefault and TableLayout properties.
Please let me know if this works for you.
Issue 2 is resolved by setting the TableLayout to Auto in DropdownLayout and also by setting the DropdownWidth. Thanks for that info!
But issue 1 is not resolved by setting visible="false" for the controls. They are not visible even after entering the cells of the grid in edit mode. We need to program them by setting the visible property to true again. It shouldn't be the case. I've seen ASP.Net samples of Infragistics controls and they didn't set any such property.
Here I am giving the markup of my grid and also code where I set EditorControlID:
***
<igtbl:UltraWebGrid id="AdobeProofSummaryGrid" runat="server" oninitializelayout="AdobeProofSummaryGrid__InitializeLayout"> <DisplayLayout CompactRendering="False" StationaryMargins="Header" AllowSortingDefault="OnClient" RowHeightDefault="20px" AllowColumnMovingDefault="OnServer" SelectTypeCellDefault="Extended" BorderCollapseDefault="Separate" AllowColSizingDefault="Free" CellClickActionDefault="Edit" AllowUpdateDefault="Yes" AllowDeleteDefault="Yes" AllowAddNewDefault="Yes" RowSelectorsDefault="No" HeaderClickActionDefault="SortMulti" Version="4.00" ViewType="Flat" Name="AdobeProofSummaryGrid"> <HeaderStyleDefault BackColor="#606060" Font-Bold="True" Font-Names="Verdana" Font-Size="10pt" ForeColor="White" HorizontalAlign="Left" VerticalAlign="Middle"> </HeaderStyleDefault> <RowStyleDefault TextOverflow="Ellipsis" VerticalAlign="Middle" BorderWidth="1px" Font-Size="8pt" Font-Names="Verdana" BorderColor="Silver" BorderStyle="Solid" HorizontalAlign="Left" ForeColor="Black" BackColor="Window"> <Padding Left="3px"></Padding> </RowStyleDefault> <SelectedRowStyleDefault ForeColor="Black" BackColor="LightSteelBlue"> </SelectedRowStyleDefault> <ActivationObject BorderColor="" BorderWidth=""> </ActivationObject> </DisplayLayout> <Bands> <igtbl:UltraGridBand> <Columns> </Columns> <AddNewRow View="NotSet" Visible="NotSet"> </AddNewRow> </igtbl:UltraGridBand> </Bands> </igtbl:UltraWebGrid>
In the InitializeLayout:
e.Layout.Bands[0].Columns.FromKey("Comments").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList; e.Layout.Bands[0].Columns.FromKey("Comments").EditorControlID = "CommentsSignoffCombo";
Hope this helps.
Please let me know if I am missing something somewhere!
I think the reason for displaying both the control out side the grid is then sequence of the page events.
Most of the samples which are provide have binding of data in first load time only, so the controls get bound with the grid on first rendering only.
But I think in your case both the controls remain independent until initialize layout gets triggered and so they are displayed as separate controls on the form.
Does this make sense?
Also check: does initialize layout gets executed when your page is first time displayed?
Could you also try following?
Bind the combo to grid just after you call grid.DataBind() instead of binding them in initialize layout event.
Or use grid.columns instead of e.layout.bands[0].columns
I had also encountered similar issue but I am not sure that I am setting visible = true. But I remember that I was binding the combo just after I call grid.DataBind(). I would update you after confirming this.
Still you could try this and let me know if this works for you.
Thank you for the quick reply. I've tested and it works fine. I couldn't bind the grid at initial page load as there won't be any data. But, in case if I use Bands and specify columns there with the EditorControlID, the controls won't appear seperately as they were earlier. But now, the problem is - when I am actually binding the grid with a dataset, the column list is getting doubled. But, I think I can figure it out. If you already have an idea, please let me know. Anyhow, thanks a lot for the information.
You could set specific column hidden using Hidden property of column object.
But I recommend not using columns in bands in aspx and set editor control id just to resolve this issue.
Because it may consume extra memory, processing and degrade performance. I suggest to use visible = true when your actual bind happens.
By the way I have seen and found that I am using visible = true explicitly.
Specifying bands, columns and EditorControlID is memory intensive and degrades performance? I don't know that. Anyhow, I've removed that and made the two controls invisible in the initial page load. Then, I've set their visible property to true just after binding the data and just before setting the grid layout. Unfortunately, I am not getting these controls visible in the respective columns. Instead, the cell just becomes editable and it appears as though I am editing that cell as a text control. Here is some sample code and snapshot:
private void SetGridLayout(LayoutEventArgs e) { DynamicWebDateChooser.Visible = true; CommentsSignoffCombo.Visible = true; e.Layout.Bands[0].Columns.FromKey("ProofID").Hidden = true; e.Layout.Bands[0].Columns.FromKey("FundID").Hidden = true; e.Layout.Bands[0].Columns.FromKey("ProofTypeID").Hidden = true; e.Layout.Bands[0].Columns.FromKey("ProofVersion").Hidden = true; e.Layout.Bands[0].Columns.FromKey("NotesFromBank").Header.Caption = "Additional Notes"; e.Layout.Bands[0].Columns.FromKey("DateSent").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom; e.Layout.Bands[0].Columns.FromKey("DateSent").EditorControlID = "DynamicWebDateChooser"; e.Layout.Bands[0].Columns.FromKey("DateReturned").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom; e.Layout.Bands[0].Columns.FromKey("DateReturned").EditorControlID = "DynamicWebDateChooser"; e.Layout.Bands[0].Columns.FromKey("Comments").Header.Caption = "Commments/Signoff"; e.Layout.Bands[0].Columns.FromKey("Comments").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.DropDownList; e.Layout.Bands[0].Columns.FromKey("Comments").EditorControlID = "CommentsSignoffCombo";
}
I mean when you bind the columns two times one using server side code and another using band, it become memory intensive as grid holds two columns. Also grid needs to process them.
I can see both the controls were visible and working fine in the first two screenshots on the top images in your first thread entry. Have you changed any thing?
But still you could try this:
e.Layout.Bands[0].Columns.FromKey("DateSent").EditorControlID = DynamicWebDateChooser.UniqueID;
If you are using master page or user controls then id of controls get changed. So we need to use controls properties like ID/UniqueID/ClientID.
Greetings