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

Disappearing columns

3 Answers 57 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 07 Feb 2014, 03:32 PM
Hi,

I have a Grid in a page where I have updated the Radcontrols from version 2009.2.701 to 2013.2.611

The grid (code below) contains some databound columns and then a template column.
Now, when the grid is displayed, only the template column shows even though the databound columns are set to visible. Previously all visible columns were displayed as expected.

Does anyone have any idea how I can fix this?

Thank you

Paul


<rad:radgrid id="CheckListGrid" runat="server" AutoGenerateColumns="False" GroupingEnabled="False"
  style="position:absolute; top:73px; left:0px" width="900px" height="515px"
   EnableEmbeddedSkins="False" Skin="XLogixBlue" CellSpacing="0" GridLines="None">
  <clientsettings>
    <scrolling AllowScroll="true" scrollheight="500px" usestaticheaders="true"/>
    <Selecting AllowRowSelect="true" />
  </clientsettings>
  <mastertableview width="880px">
    <columns>
      <rad:GridBoundColumn UniqueName="iCheckItemID" DataField="iCheckItemID" display="false" ></rad:GridBoundColumn>
      <rad:GridBoundColumn UniqueName="sDataType" DataField="sDataType" display="false"></rad:GridBoundColumn>
       
      <rad:GridBoundColumn UniqueName="CheckDescription" DataField="CheckDescription" HeaderText="Description" Visible="true">
        <HeaderStyle width="280px"/>
        <ItemStyle width="280px" height="40px" Font-Size="Larger" font-bold="true"/>
      </rad:GridBoundColumn>
      <rad:GridBoundColumn UniqueName="CategoryDescription" DataField="CategoryDescription" HeaderText="Category">
        <HeaderStyle width="70px"/>
        <ItemStyle width="70px" height="40px"/>
      </rad:GridBoundColumn>
      <rad:GridBoundColumn UniqueName="bMandatory" DataField="bMandatory" HeaderText="Mandatory">
        <HeaderStyle width="55px"/>
        <ItemStyle width="55px" height="40px"/>
      </rad:GridBoundColumn>
      <rad:GridBoundColumn UniqueName="sRange" DataField="sRange" HeaderText="Range">
        <HeaderStyle width="100px"/>
        <ItemStyle width="100px" height="40px" Font-Size="Larger" font-bold="true"/>
      </rad:GridBoundColumn>
       
      <rad:GridTemplateColumn UniqueName="ValueTemplate" HeaderText="Entry">
        <HeaderStyle width="270px"/>
        <ItemStyle width="270px" height="40px"/>
        <ItemTemplate>
          <asp:panel id="UploadPanel" runat="server" style="display:none; text-align:left">
            <asp:FileUpload id="CheckItemUpload" runat="server" width="270px" onkeydown="return false;"/>
          </asp:panel>
          <asp:panel id="ConfirmPanel" runat="server" style="display:none; text-align:center">
            <input type="button" id="ConfirmYes" value="Yes" style="width:80px; height:35px; background-color:Silver" onclick="ToggleConfirmButton(this);"/>
            <input type="button" id="ConfirmNo" value="No" style="width:80px; height:35px; background-color:Silver" onclick="ToggleConfirmButton(this);"/>
            <input type="hidden" id="ConfirmResult" runat="server" value="" />
          </asp:panel>
          <asp:panel id="TextBoxPanel" runat="server" style="display:none; text-align:left">
            <asp:textbox id="CheckItemTextBox" runat="server" width="210px"></asp:textbox>
            <img id="WorksOrderKeyboard" alt="Show Keyboard" src="/XLogix/Images/Icon Buttons/Keyboard Btn.png" runat="server"/>
          </asp:panel>
          <asp:panel id="DropDownPanel" runat="server" style="display:none; text-align:left">
            <asp:dropdownlist id="CheckItemDropDown" runat="server" dataTextField="sDescription" DatavalueField="iCheckItemOptionID" width="270px"
              font-size="Large"></asp:dropdownlist>
          </asp:panel>
        </ItemTemplate>
      </rad:GridTemplateColumn>
       
    </columns>
  </mastertableview>
</rad:radgrid>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2014, 05:51 AM
Hi Paul,

I'm not sure how you are binding the RadGrid. Please use Advanced Data-binding (using NeedDataSource event) to bind the data to the RadGrid. Make sure you have not set Display/Visible as false. If this doesn't help, please provide your C#/VB code snippet.

Thanks,
Princy
0
Paul
Top achievements
Rank 1
answered on 10 Feb 2014, 10:55 AM
Hi,

Thanks for your response.
It wasn't using the OnNeedDataSource event, so I have now changed it to do so, but it hasn't made any difference.

The code is shown below, but there doesn't appear to be anything in there that is hiding the other columns.
(Apologies for the code - it's a bit of a mess - I inherited it and have not had chance to tidy it up properly yet.)


Thank you

Paul

  Protected Sub CheckListGrid_NeedDataSource(sender As Object, e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles CheckListGrid.NeedDataSource
    LoadCheckSheet()
  End Sub
 
'******************************************************************
 
  Protected Sub CheckListGrid_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles CheckListGrid.ItemDataBound
 
    If TypeOf e.Item Is GridDataItem Then
      Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
 
      Dim flowOrder As Integer = -1
      Integer.TryParse(item("iFlowOrder").Text, flowOrder)
 
      If flowOrder <> -1 Then
        If conditions.IndexOf(flowOrder) <> -1 Then
          item.Display = False
        End If
      End If
 
      Select Case item("sDataType").Text
        Case "Boolean"
          SetBooleanState(item)
        Case "Selection"
          SetSelectionState(item)
        Case "Image"
          SetUploadState(item)
        Case Else
          SetTextState(item, item("sDataType").Text)
 
      End Select
 
    End If
  End Sub
 
'******************************************************************
 
  Private Sub LoadCheckSheet()
    Dim CheckList As SPTblCheckLists = New SPTblCheckLists()
    CheckList.ICheckListID = Common.CheckSheetID
    Dim CheckSheet As DataTable = CheckList.Select_OneByCheckLIstID
    CheckList.Dispose()
 
    If CheckSheet.Rows.Count > 0 Then
      CheckSheetName.Text = CheckSheet.Rows(0)("sName").ToString()
      'WorksOrderNumber.Text = String.Empty
      CheckSheetType.Text = CheckSheet.Rows(0)("sDescription").ToString()
      CheckSheetStart.Text = DateTime.Now.ToString()
 
      PDFViewCS.Attributes("onclick") = String.Format("OpenPDFWindow('{0}','{1}');", CheckList.ICheckListID, "To Do") 'Master.XLCommon.UserName)
 
      LoadCheckSheetItems()
    Else
      SelectCheckSheetFromList()
    End If
  End Sub
 
'******************************************************************
 
  Private Sub LoadCheckSheetItems()
    Dim CheckListItems As SPTblCheckListItems = New SPTblCheckListItems()
    CheckListItems.ICheckListID = Common.CheckSheetID
    Dim CheckSheetItems As DataTable = CheckListItems.SelectAll_ByCheckListID()
    CheckListItems.Dispose()
 
    If (CheckSheetItems.Rows.Count > 0) Then
 
      For Each row As DataRow In CheckSheetItems.Rows
        If row("sDataType").ToString() = "Boolean" Then
          Dim yesResult As Integer = -1
          Dim noResult As Integer = -1
 
          Integer.TryParse(row("iFlowAcceptNext").ToString(), yesResult)
          Integer.TryParse(row("iFlowDeclineNext").ToString(), noResult)
 
          If yesResult > 0 Then
            If conditions.IndexOf(yesResult) = -1 Then
              conditions.Add(yesResult)
            End If
          End If
 
          If noResult > 0 Then
            If conditions.IndexOf(noResult) = -1 Then
              conditions.Add(noResult)
            End If
          End If
 
        End If
      Next
 
      CheckListGrid.DataSource = CheckSheetItems
      'CheckListGrid.DataBind()
    Else
      CheckListGrid.DataSource = New DataTable
      'CheckListGrid.DataBind()
    End If
  End Sub
 
'******************************************************************
 
  Private Sub SetBooleanState(ByVal item As GridDataItem)
    item("sRange").Text = "Yes/No"
    Dim panel As Panel = DirectCast(item("ValueTemplate").FindControl("ConfirmPanel"), Panel)
    panel.Style("display") = ""
    panel.Attributes("iCheckItemID") = item("iCheckItemID").Text
    panel.Attributes("iAcceptNext") = item("iFlowAcceptNext").Text
    panel.Attributes("iDeclineNext") = item("iFlowDeclineNext").Text
  End Sub
 
'******************************************************************
 
  Private Sub SetUploadState(ByVal item As GridDataItem)
    item("sRange").Text = "Browse for file"
    Dim panel As Panel = DirectCast(item("ValueTemplate").FindControl("UploadPanel"), Panel)
    panel.Style("display") = ""
  End Sub
 
'******************************************************************
 
  Private Sub SetSelectionState(ByVal item As GridDataItem)
    item("sRange").Text = "Select from List"
    Dim panel As Panel = DirectCast(item("ValueTemplate").FindControl("DropDownPanel"), Panel)
    panel.Style("display") = ""
 
    Dim cli As SPTblCheckListItems = New SPTblCheckListItems
    Dim ddl As DropDownList = DirectCast(panel.Controls(1), DropDownList)
    ddl.DataSource = cli.SelectAll_CheckItemOptions(item("iCheckItemID").Text)
    ddl.DataBind()
 
  End Sub
 
'******************************************************************
 
  Private Sub SetTextState(ByVal item As GridDataItem, ByVal DataType As String)
    Dim panel As Panel = DirectCast(item("ValueTemplate").FindControl("TextBoxPanel"), Panel)
    Dim valueBox As TextBox = DirectCast(panel.FindControl("CheckItemTextBox"), TextBox)
    Dim keyboard As HtmlImage = DirectCast(item("ValueTemplate").FindControl("WorksOrderKeyboard"), HtmlImage)
 
    panel.Style("display") = ""
 
    If DataType = "PDACS" Then
      keyboard.Style("display") = "none"
    End If
 
    Select Case DataType
      Case "Float"
        item("sRange").Text = String.Format("Target:{0}-{1} Allowed:{2}-{3}", item("fTargetMin").Text, item("fTargetMax").Text _
          , item("fMinValue").Text, item("fMaxValue").Text)
        keyboard.Attributes("onclick") = "ShowKeyboard(" + valueBox.ClientID + ", 'Number', " + item("fMinValue").Text + ", " + item("fMaxValue").Text + ")"
        valueBox.Attributes("onblur") = "UpdateNumberValue(this, this.value, " + item("fMinValue").Text + ", " + item("fMaxValue").Text + ")"
      Case "Number"
        item("sRange").Text = String.Format("Target:{0}-{1} Allowed:{2}-{3}", item("fTargetMin").Text, item("fTargetMax").Text _
        , item("fMinValue").Text, item("fMaxValue").Text)
        keyboard.Attributes("onclick") = "ShowKeyboard(" + valueBox.ClientID + ", 'Number', " + item("fMinValue").Text + ", " + item("fMaxValue").Text + ")"
       ' valueBox.Attributes("onblur") = "UpdateNumberValue(this, this.value, " + item("fMinValue").Text + ", "   + item("fMaxValue").Text + ")"
        valueBox.Attributes("onblur") = "CheckBBD(" + valueBox.ClientID + ", " + item("iCheckItemID").Text + ")"
      Case "PDACS"
        item("sRange").Text = "External source"
        valueBox.Enabled = False
        Dim iPLCID As Integer = 0
        Dim iPLCTagID As Integer = 0
        Integer.TryParse(item("iPLCListID").Text, iPLCID)
        Integer.TryParse(item("iPLCTagsID").Text, iPLCTagID)
        'valueBox.Text = Common.GetPDACSValue(iPLCID, iPLCTagID)
      Case "String"
        Dim maxLength As Integer = 10
        Integer.TryParse(item("iDataLength").Text, maxLength)
        valueBox.MaxLength = maxLength
        item("sRange").Text = String.Format("Max {0} characters", maxLength)
        keyboard.Attributes("onclick") = "ShowKeyboard(" + valueBox.ClientID + ", 'Text')"
        valueBox.Attributes("onblur") = "CheckBBD(" + valueBox.ClientID + ", " + item("iCheckItemID").Text + ")"
        'valueBox.Attributes("onblur") = "CheckBBD(" + valueBox.ClientID + ", " + item("iCheckItemID").Text + ", " + valueBox.Text + ")"
      Case "Time"
        item("sRange").Text = "Time"
        valueBox.Attributes("onblur") = "UpdateTimeValue(this, this.value)"
        keyboard.Attributes("onclick") = "ShowKeyboard(" + valueBox.ClientID + ", 'Text')"
        valueBox.Text = Now
    End Select
 
  End Sub



0
Viktor Tachev
Telerik team
answered on 12 Feb 2014, 09:29 AM
Hi Paul,

The issue you are experiencing seems rather strange. From the provided markup and code it looks like only the first two columns in RadGrid should be hidden. The rest should be displayed as expected. Would you provide a screenshot of how RadGrid looks like when it is rendered on the page?

Also note that if you are using Visual Studio 2013 there could be issues with the way the grid is rendered. It is recommended to use the latest version of our controls (currently 2013.3.1324) as it supports the new Visual Studio.

Regards,
Viktor Tachev
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Paul
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Paul
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or