Getting Amount Field value from RagGrid.

3 posts, 0 answers
  1. Venkateswarlu
    Venkateswarlu avatar
    13 posts
    Member since:
    Jun 2013

    Posted 14 Jul 2014 Link to this post

    Hi Sir,

    I am having an issue, After double clicking on RadGrid Record then  through GetDatakeyValue i am getting vaue but not getting value with thousand operator.
     
    -->Suppose in Raggrid displayed Amoun Field values is:$1,500.00
    -->by using GetDataKeyValue getting value is:1500 not like the above.

    If you have an idea please suggest to me sir.

    Script:<script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                var grid = $find("<%= RadGrid1.ClientID %>");
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                var key = MasterTable.getCellByColumnUniqueName(row, "EmpID");
                var ID = key.innerHTML;
                MasterTable.fireCommand("DblClick", ID);
            }
        </script>

     ASPX:
    ---------

                    <telerik:GridBoundColumn DataFormatString="{0:C2}" DataField="Amount" HeaderText="Amount"
                        UniqueName="Amount" Visible="true" Display="true" HeaderStyle-HorizontalAlign="Center"
                        ItemStyle-HorizontalAlign="Center">
                    </telerik:GridBoundColumn>

     Code Behind:
     ------------------
       protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
        {
        
            if (e.CommandName == "DblClick")
            {
               GridDataItem item = (GridDataItem)RadGrid1.SelectedItems[0];
               Session["Amount"] = item.GetDataKeyValue("Amount").ToString();
            }
       }

      
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 15 Jul 2014 in reply to Venkateswarlu Link to this post

    Hi Venkateswarlu,

    Please have a look into the sample code snippet which works fine at my end.

    ASPX:
    <telerik:RadGrid ID="rgrdAmount" runat="server" DataSourceID="sqldsAmount" AutoGenerateColumns="false" OnItemCommand="rgrdAmount_ItemCommand">
        <MasterTableView DataKeyNames="Amount">
            <Columns>
                <telerik:GridBoundColumn DataField="EmpID" HeaderText="EmpID" UniqueName="EmpID">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Amount" HeaderText="Amount" UniqueName="Amount">
                </telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
    </telerik:RadGrid>

    C#:
    protected void rgrdAmount_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
    {
        if (e.CommandName == "DblClick")
        {
            int index = Convert.ToInt16(e.CommandArgument);
            string value = string.Empty;
            GridDataItem item1 = (GridDataItem)rgrdAmount.Items[index];
            Session["Amount"] = value= item1.GetDataKeyValue("Amount").ToString();
        }
    }

    JavaScript:
    function RowDblClick(sender, eventArgs) {
        var radGrid = $find("<%= rgrdAmount.ClientID %>");
        var masterTable = radGrid.get_masterTableView();
        var selectedItemIndex = eventArgs.get_itemIndexHierarchical();
        masterTable.fireCommand("DblClick", selectedItemIndex);
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Venkateswarlu
    Venkateswarlu avatar
    13 posts
    Member since:
    Jun 2013

    Posted 16 Jul 2014 in reply to Shinu Link to this post

    Hi Sir,

    It is working fine, Thank you
Back to Top