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

Getting Amount Field value from RagGrid.

2 Answers 18 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Venkateswarlu
Top achievements
Rank 1
Venkateswarlu asked on 14 Jul 2014, 09:25 AM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 15 Jul 2014, 12:10 PM
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.
0
Venkateswarlu
Top achievements
Rank 1
answered on 16 Jul 2014, 05:28 AM
Hi Sir,

It is working fine, Thank you
Tags
General Discussions
Asked by
Venkateswarlu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Venkateswarlu
Top achievements
Rank 1
Share this question
or