Site Search:
Sign in | Join | Help
4Penny.net

ComponentArt

Example of a grid inside of a callback control, populated with a dropdown list

This example shows a form with a callback control, dropdown and a grid. Changing the dropdown causes the grid to repopulate without posting back. First the frontside code:

<script type="text/javascript">
        function renderControl(param) { 
            <%= Callback1.ClientObjectId %>.Callback(param); 
        } 
    </script>


<br ID="ddlGroup" runat="server" />
    <ComponentArt:CallBack ID="Callback1" runat="server" Debug="false" >


    <LoadingPanelClientTemplate>
              <table cellspacing="20" cellpadding="0" border="0" style="background-color: White; border:solid 1px black ">
                  <tr>
                      <td style="font-size: 10px;">
                          Loading...&nbsp;</td>
                      <td>
                          </td alt="loading..." src="../images/spinner.gif" width="16" height="16" border="0">
                  </tr>
              </table>
    </LoadingPanelClientTemplate>

    </ComponentArt:CallBack>



    <ComponentArt:Grid id="Grid1" Visible="false"
        PreExpandOnGroup="true" 
        RunningMode="Callback"
        EnableViewState="false"
        EditOnClickSelectedItem="false"
        AllowEditing="true"
        AutoCallBackOnInsert="true"
        AutoCallBackOnUpdate="true"
        AutoCallBackOnDelete="true"
        ShowHeader="False"
        CssClass="Grid"
        LoadingPanelClientTemplateId="LoadingFeedbackTemplate"
        LoadingPanelPosition="MiddleCenter"


        ShowFooter="true" FooterCssClass="GridFooter2"
        IndentCellWidth="19"
        IndentCellCssClass="IndentCell"
        TreeLineImageWidth="22"
        TreeLineImageHeight="19"
        PageSize="15" 
        PagerStyle="Numbered" 
        PagerTextCssClass="PagerText"
        ImagesBaseUrl="~/images/"
        TreeLineImagesFolderUrl="~/images/lines/" 
        Width="500"
        runat="server" >
        <Levels>
          <ComponentArt:GridLevel
          
            ShowTableHeading="false"
            SortImageWidth="10"
            SortImageHeight="10"
            EditCellCssClass="EditDataCell"
            EditFieldCssClass="EditDataField"


            DataMember="Header"
            DataKeyField="lRowID" 
            SelectedRowCssClass="SelectedRow" 
            HeadingTextCssClass="HeadingText"
            HeadingCellCssClass="HeadingCell"
            RowCssClass="Row"
            HeadingRowCssClass="HeadingRow"
            TableHeadingCssClass="TableHeading"
            GroupHeadingCssClass="TableHeading"
            SortDescendingImageUrl="desc.gif"
            SortAscendingImageUrl="asc.gif"
            DataCellCssClass="DataCell"
            ShowSelectorCells="false">
              <Columns>
                <ComponentArt:GridColumn AllowEditing="false" DataField="lRowID" visible="false"  />
                <ComponentArt:GridColumn AllowEditing="false" DataField="sObjectName"  />
                <ComponentArt:GridColumn AllowEditing="false" DataField="fullPerms" HeadingText="Form Name"  />
                <ComponentArt:GridColumn AllowEditing="false" DataField="readPerms" HeadingText="Form Name"  />
              </Columns>
          </ComponentArt:GridLevel>


        </Levels>
    </ComponentArt:Grid>

Then the code behind:

Imports System.Data


Partial Class utilities_test
    Inherits System.Web.UI.Page
    Dim ofacHierarchy As New dynDataOld.facHierarchy
    Dim ofacGroups As New dynDataOld.facGroups
    Dim mintGroupID As String
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


        'set the connection string on the data factory
        ofacGroups.ConnectionString = Session("connect")
        ofacHierarchy.ConnectionString = Session("connect")


        mintGroupID = 23



        If Not Page.IsPostBack Then
            buildCombo()
            Me.ddlGroup.Attributes.Add("onchange", "renderControl(this.options[this.selectedIndex].value)")
        End If
    End Sub
    Sub buildCombo()
        Me.ddlGroup.DataSource = ofacGroups.OEDGroups_SEL
        Me.ddlGroup.DataValueField = "lRowID"
        Me.ddlGroup.DataTextField = "sGroupName"
        Me.ddlGroup.DataBind()


    End Sub
    Sub buildGrid(ByVal intGroupID As System.Int16)
        'bind the datagrid
        Dim oDT As DataTable
        Dim oTable1 As DataTable
        oDT = ofacHierarchy.OEDHierarchy_SEL_byGroupL2(intGroupID)
        oTable1 = oDT.Copy
        oTable1.TableName = "Header"


        Dim dsSrc As New DataSet
        dsSrc.Tables.Add(oTable1)


        Grid1.DataSource = dsSrc
        Grid1.DataBind()
    End Sub
    Public Sub CallBack1_Callback(ByVal sender As Object, ByVal e As ComponentArt.Web.UI.CallBackEventArgs) Handles Callback1.Callback
        Grid1.Visible = True
        buildGrid(e.Parameter)
        Grid1.RenderControl(e.Output)


    End Sub


End Class



 

Comments

No Comments

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.