Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
65
WebDropDown Editor in child band not initially showing TextField value
posted

Hi, I am new to using the HierarchicalDataGrid but am really liking it so far.  I've gotten everything working pretty easily by using the samples as a guide, but I'm having one issue that I don't know how to resolve.  I have two columns in both the main grid itself and in the single band that I've setup that use webdropdown editors for editing the data.  I have bound the webdropdown editor to a datasource and set the TextField and ValueField properties accordingly.

When the grid displays, the columns in the main grid are correctly displaying the TextField string and not the underlying value and I can edit them using the webdropdown with no problem.  However when I expand a row and open up the child band, the two columns are displaying the ValueField value and not the TextField value (in this case an integer).  When I double click on the cell I do get the webdropdown editor and if I select a value and leave that cell, it then displays the TextField value instead of the ValueField like it's supposed to.  So the problem just appears to be on the initial binding of the grid that it's not using the right field.  I'm sure I am just missing something, but not sure what.

I have included a screenshot of what I'm talking about as well as snippets of both the control declaration in the code-front and the code in the code-behind. 

Thanks for your help (this is an awesome control!)

Code-front code:

<!-- Role/Position Assignments grid -->
<ig:WebHierarchicalDataGrid ID="whdgAssignments" runat="server"
Height="400px"
Width="650px"
InitialDataBindDepth="-1"
AutoGenerateColumns="false"
AutoGenerateBands="false"
DataKeyFields="sysID"
>
<Columns>
    <ig:BoundDataField DataFieldName="RoleName" Key="RoleName"></ig:BoundDataField>
    <ig:BoundDataField DataFieldName="InternalEnforcement" Key="InternalEnforcement" Header-Text="Internal"></ig:BoundDataField>
    <ig:BoundDataField DataFieldName="ExternalEnforcement" Key="ExternalEnforcement" Header-Text="External"></ig:BoundDataField>
</Columns>
<Bands>
    <ig:Band DataMember="positions" Key="positions" ShowHeader="false" ShowFooter="false"
     IsSelfReference="false" AutoGenerateColumns="false" DataKeyFields="sysID">
 <Columns>
     <ig:BoundDataField DataFieldName="txtName" Key="txtName"></ig:BoundDataField>
     <ig:BoundDataField DataFieldName="InternalEnforcement" Key="InternalEnforcement"></ig:BoundDataField>
     <ig:BoundDataField DataFieldName="ExternalEnforcement" Key="ExternalEnforcement"></ig:BoundDataField>
 </Columns>
 <Behaviors>
     <ig:EditingCore>
  <Behaviors>
      <ig:CellEditing Enabled="true">
   <ColumnSettings>
       <ig:EditingColumnSetting ColumnKey="InternalEnforcement" EditorID="EnforcementEditor" />
       <ig:EditingColumnSetting ColumnKey="ExternalEnforcement" EditorID="EnforcementEditor" />
   </ColumnSettings>
      </ig:CellEditing>
  </Behaviors>
     </ig:EditingCore>
 </Behaviors>
    </ig:Band>
</Bands>
<EditorProviders>
    <ig:DropDownProvider ID="EnforcementEditor">
 <EditorControl ID="EditorControl1" runat="server" DisplayMode="DropDownList" width="165">
     <ClientEvents DropDownOpening="DropDownOpening" />
 </EditorControl>
    </ig:DropDownProvider>
</EditorProviders>
<Behaviors>
    <ig:EditingCore>
 <Behaviors>
     <ig:CellEditing Enabled="true" EnableInheritance="true">
  <ColumnSettings>
      <ig:EditingColumnSetting ColumnKey="InternalEnforcement" EditorID="EnforcementEditor" />
      <ig:EditingColumnSetting ColumnKey="ExternalEnforcement" EditorID="EnforcementEditor" />
  </ColumnSettings>
     </ig:CellEditing>
 </Behaviors>
    </ig:EditingCore>
</Behaviors>
</ig:WebHierarchicalDataGrid>

Code-behind code

' setup the webdropdown editor and bind it's data
Dim EnforcementEditor As WebDropDown = CType(whdgAssignments.EditorProviders("EnforcementEditor").GetEditor(), WebDropDown)
EnforcementEditor.DataSource = _dvEnforcements
EnforcementEditor.TextField = "Name"
EnforcementEditor.ValueField = "ID"
EnforcementEditor.DataBind()


' get the data needed for the Hierarchical data source

' create the parent 'roles' dataview
Dim roleView As New Infragistics.Web.UI.DataSourceControls.DataView()
roleView.DataSource = DistrictApplicantRole.GetFormDistrictApplicantRoleEnforcements(DistrictSessionManager.DistrictId, DistrictFormID)
roleView.ID = "roles"
WebHierarchicalDataSource1.DataViews.Add(roleView)

' create the child 'positions' dataview
Dim positionView As New Infragistics.Web.UI.DataSourceControls.DataView()
positionView.DataSource = Position.GetFormPositionEnforcements(DistrictSessionManager.DistrictId, DistrictFormID)
positionView.ID = "positions"
WebHierarchicalDataSource1.DataViews.Add(positionView)

' create the data relation
Dim relation As New Infragistics.Web.UI.DataSourceControls.DataRelation()
' specify the parent info
relation.ParentDataViewID = "roles"
relation.ParentColumns = New String() {"sysID"}
' specify the child info
relation.ChildDataViewID = "positions"
relation.ChildColumns = New String() {"sysCoreDistrictApplicantRoleID"}
' add the relation to the data source
WebHierarchicalDataSource1.DataRelations.Add(relation)

' bind the grid
whdgAssignments.DataSource = WebHierarchicalDataSource1
whdgAssignments.DataBind()