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

RadGrid Footeritem in a function

5 Answers 274 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Satya Sahu
Top achievements
Rank 1
Satya Sahu asked on 05 Apr 2010, 12:57 PM
Hi Folks can anyone let me know how to access the RadgridFooteritem in a function like

function foo()

{
how to access the RadgridFooteritem????
}

Awaiting for your reply.


Thanks
Satya

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Apr 2010, 01:33 PM

Hi Satya,

To obtain reference to the grid footer item, you should use get_masterTableViewFooter() method. You can get the HTML table element of the grid footer as follows:

                var footerTable = grid.get_masterTableViewFooter().get_element();

If you are not using Static Headers and Scrolling, then try the following client side code.

JavaScript:

 
<script type="text/javascript">   
function getFooter()   
{   
    var masterTable = $find("<%= RadGrid1.ClientID%>").get_masterTableView();    
    var footer = masterTable.get_element().getElementsByTagName("TFOOT")[0];  
       . . .  
}   
</script>  

Hope this helps,

Shinu.

0
Satya Sahu
Top achievements
Rank 1
answered on 06 Apr 2010, 06:27 AM
Hi Shinu....

Thanks for your reply.

But i dont want to get the footerrow in my aspx .

I am trying to get in my code behind.

Can you help me on that.

My Code looks like this:-
    Public Sub CreateShapeParameter(ByVal strParamVal As String, ByVal intRowIndex As Integer, ByVal intShapeItem As Integer) 
        Try 
 
 
            'Call sp and get return val 
            Dim lnkShape As New LinkButton 
            Dim intShapeTransHeader As Integer = 0 
            Dim ddlShape As New DropDownList 
            If (intRowIndex > -1) Then  '0) Then 
                lnkShape = CType(gvRadStructDetails.Items(intRowIndex).FindControl("lnkShape"), LinkButton) 
                ddlShape = CType(gvRadStructDetails.Items(intRowIndex).FindControl("ddlShape"), DropDownList) 
            Else 
                lnkShape = CType(gvStructDetails.FooterRow.FindControl("lnkShape"), LinkButton) 
                ddlShape = CType(gvStructDetails.FooterRow.FindControl("ddlShape"), DropDownList) 
            End If 
            objDetailInfo.intShapeTransHeaderId = lnkShape.Text 
            objDetailInfo.intShapeId = intShapeItem 
            objDetailInfo.vchShapeDescription = GetLocalResourceObject("strShapeDescription") 
            objDetailInfo.nvchParamValues = strParamVal 
            objDetailInfo.intUserid = ViewState("UserId") 
 
            Using objTS As System.Transactions.TransactionScope = New System.Transactions.TransactionScope 
 
                intShapeTransHeader = getdata(3, "InsertShapeValFrmTC") 
                objTS.Complete() 
            End Using 
            lnkShape.Text = intShapeTransHeader 
 
            ''''Shape Set 
            Dim strHTMLShapeURL As String = "javascript:OpenShapeModalDialog('../ShapePopUp.aspx?intTransHeaderId=" + lnkShape.Text + "&intShapeId=" + ddlShape.SelectedValue + "&FromPage=ColumnCage');" 
            If (intRowIndex = -1) Then 
                CType(gvStructDetails.FooterRow.FindControl("shapeLink"), HtmlAnchor).Attributes.Add("href", strHTMLShapeURL) 
            Else 
                CType(gvStructDetails.Rows(intRowIndex).FindControl("shapeLink"), HtmlAnchor).Attributes.Add("href", strHTMLShapeURL) 
            End If 
 
        Catch ex As Exception 
            ErrorHandler.RaiseError(ex, strLogError) 
        End Try 
    End Sub 

0
Shinu
Top achievements
Rank 2
answered on 06 Apr 2010, 07:28 AM

Hello Satya Sahu,

You could use the following code in order to get access to footer item of grid.

C#:

 
GridFooterItem footeritem = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0]; 

-Shinu.

0
kollam2003
Top achievements
Rank 1
answered on 14 Mar 2013, 09:34 AM
I'm getting the error: "{System.IndexOutOfRangeException: Index was outside the bounds of the array." when using the above code. I'm using the below code. I want the value of  "Total UnitStock"

<telerik:GridTemplateColumn UniqueName="UnitStock" HeaderText="Unit Stock" DataField="UnitStock"    SortExpression="UnitStock" ItemStyle-Width="15%" HeaderStyle-Width="15%" FilterControlWidth="20%"  AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" Aggregate="Sum" FooterText="Total Unit Stock : ">
   <ItemTemplate>
    <asp:Label ID="lblUnitStock" runat="server" Text='<%#Eval("UnitStock") %>'></asp:Label>
   </ItemTemplate>
</telerik:GridTemplateColumn>
0
kollam2003
Top achievements
Rank 1
answered on 14 Mar 2013, 09:49 AM
I got it

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
      {
         if (e.Item is GridFooterItem)
          {
              GridFooterItem footeritem = (GridFooterItem)RadGrid1.MasterTableView.GetItems(GridItemType.Footer)[0];
              string _UnitStock = footeritem["UnitStock"].Text.Split(':')[1];
              
          }
      }
Tags
Grid
Asked by
Satya Sahu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Satya Sahu
Top achievements
Rank 1
kollam2003
Top achievements
Rank 1
Share this question
or