Site Search:
Sign in | Join | Help

This Blog

Syndication

Tags

ComponentArt

August 2007 - Posts

  • Creating an editable textbox inside a Componentart Grid

    This will demonstrate how to create an editable textbox inside of a janus grid, and then how to update the dataset with the new data.

    Add a column in the grid that references a 'ServerSideTemplate':

    <ComponentArt:GridColumn DataCellServerTemplateId="unitPriceTemplate" />

    Be sure that any field that you want to reference in the template is in the grid. It's OK to make it non-visible:

    <ComponentArt:GridColumn DataField="unitprce" Visible="false" />

     

    Add the template

    <ServerTemplates>
      <ComponentArt:GridServerTemplate ID
    ="unitPriceTemplate">
        <Template
    >
          <asp:TextBox runat="server" Text='<%# Container.DataItem("unitprce") %>'
     ID="unitprce"></asp:TextBox
    >
        </Template
    >
      </ComponentArt:GridServerTemplate
    >
    </ServerTemplates>

    Now we need to be able to get a reference to the template field in the code behind. In this example, we are looping through the grid using the 'getSelectedItems' method of the grid.

    Protected Sub btnRemoveHolds_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRemoveHolds.Click

    Dim griditem As ComponentArt.Web.UI.GridItem
    Dim intRowID As
    System.Int64
    Dim strSopnumber As
    String
    Dim intSoptype As
    System.Int16
    Dim intLineItemSeq As
    System.Int64
    Dim selectedItems As
    ComponentArt.Web.UI.GridItemCollection
    Dim dblUnitPrice As
    Double
    Dim txtUnitPrice As
    TextBox
    selectedItems =
    Me.grdOrders.GetCheckedItems(Me.grdOrders.Levels(0).Columns("removeHold"
    ))

    For Each griditem In selectedItems
      'get a reference to the rowID that we'll change
      strSopnumber = griditem("sopnumbe"
    )
      intSoptype = griditem(
    "soptype"
    )
      intLineItemSeq = griditem(
    "lnitmseq"
    )

      txtUnitPrice = Me.grdOrders.FindControl(0, 5, griditem, "txtUnitPrice")
      dblUnitPrice = txtUnitPrice.Text
     

      'update the price
      ofacSOP10200.SOP10200_UPD_UnitPrice(strSopnumber, intSoptype, intLineItemSeq, dblUnitPrice)

    Next

    bindgrid()


    End Sub

     

  • ComponentArt ItemCommand

    Sample code for the itemCommand:

          Protected Sub grdHolds_ItemCommand(ByVal sender As Object, ByVal e As ComponentArt.Web.UI.GridItemCommandEventArgs) Handles grdHolds.ItemCommand
            Dim strHoldType As String
            Dim lbtnEdit As New LinkButton
            lbtnEdit = e.Control
            strHoldType = lbtnEdit.CommandArgument

        End Sub

  • ComponentArt itemContentCreated and itemDataBound

    I have been using itemDataBound to hook up things in CA grids, but their docs say to use itemContentCreated. I'm sure there is not much difference.  This event will fire seperately for each template column in the row.

    Code Sample:  

     Protected Sub grdHolds_ItemContentCreated(ByVal sender As Object, ByVal e As ComponentArt.Web.UI.GridItemContentCreatedEventArgs) Handles grdHolds.ItemContentCreated

            'as the grid binds, see if the user has access to edit this type of data
            'show the 'edit' link if they have access
            Dim strHoldType As String
            Dim bShow As Boolean = False

            strHoldType = e.Item("vchrHoldType")

            'disable the link if the edit page doesnt exist
            If strHoldType = "PRICING" Or strHoldType = "MORTAR" Then
                bShow = False
            End If

            Dim lbtnEdit As New LinkButton
            lbtnEdit = e.Content.FindControl("lbtnEdit")

            lbtnEdit.Visible = bShow
        End Sub