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

RadGrid

4 Answers 168 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Manoj
Top achievements
Rank 1
Manoj asked on 26 Jan 2009, 01:15 PM
Dear All,

I've a radGrid in my form, there are 3 columns in the grid to show value. the third column will be editable (means I've put RadNumericTextBox) in it.
The rowselection also enabled in the radGrid.
Whenever user clicks on row it should execute a statement, that part is working proper. But when the user clicks on RadNumericTextBox instead of clicking the Grid Row, that row will be treated as not selected.

my doubt is, whenever user clicks any control or inside the row, then that row should be selected automatically...

how is that possible?

Thanks in Advance
Manoj Balakrishnan

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 27 Jan 2009, 06:54 AM
Hi Manoj,

You can try the following code snippet to achieve the desired scenario. Here i am accessing the RadNumericTextBox on the server side and adding an OnClick attribute to it. The RowIndex is also passed to the client side. Then in the client side we can select the row using JavaScript.

ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" AllowFiltering="False"   HeaderText="TempCol"  > 
                        <ItemTemplate> 
                            <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server"
                            </telerik:RadNumericTextBox> 
                        </ItemTemplate> 
                       </telerik:GridTemplateColumn> 

CS:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            RadNumericTextBox numtxtbx = (RadNumericTextBox)item["TempCol"].FindControl("RadNumericTextBox1"); 
            numtxtbx.Attributes.Add("OnClick""return Select('" + item.ItemIndex + "');"); 
        } 
   } 


JS:
<script type="text/javascript"
 function Select(index) 
 { 
  var masterTable = $find("<%=RadGrid1.ClientID%>").get_masterTableView(); 
  var dataItem = masterTable.get_dataItems()[index]; 
  dataItem.set_selected(true); 
 } 
</script> 


Thanks
Shinu

0
Vijay Kartha
Top achievements
Rank 1
answered on 28 Jan 2009, 12:18 PM
Hi ,
Thank you very much for fast response.

But now the problem is get_masterTableView(); which gives me error. "Object Expected". Right now i'm using little old version. Please help how can we solve this problem without upgrading the DLL.

Thanks
Manoj Balakrishnan    
0
Shinu
Top achievements
Rank 2
answered on 29 Jan 2009, 05:05 AM
Hi Manoj,

Could you specify the version of RadControls that you are using?Also your aspx code if possible.

Shinu
0
Vijay Kartha
Top achievements
Rank 1
answered on 29 Jan 2009, 05:37 AM

Hi,

I'm using RadControls  Version 6.0 with service pack Q3 2007 sp2 .

Thanks
Manoj B

 

aspx code

-----------------------------

 

  <radg:RadGrid ShowFooter="True" ID="radLists" runat="server" AllowPaging="True" AllowSorting="True"
            GridLines="None" Skin="Default" 
            PageSize="15" EnableAJAXLoadingTemplate="True" LoadingTemplateTransparency="25" Width="100%" EnableAJAX="True" ShowStatusBar="True">
            <PagerStyle Mode="NextPrevAndNumeric" />
            <MasterTableView AutoGenerateColumns="False" DataKeyNames="PKey" CommandItemDisplay="TopAndBottom">
                <Columns>
                <rad:GridClientSelectColumn UniqueName="ClientSelectColumn" Visible="False"  />
                    <rad:GridTemplateColumn DataField="VoucherNumber" HeaderText="Voucher #" UniqueName="VoucherNumber">
                        <HeaderTemplate>
<asp:LinkButton id="lbVoucherNumber" runat="server" CssClass="Link" Text="Voucher #" CommandArgument="VoucherNumber" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lbVoucherNumber_Command" BackColor="Transparent"></asp:LinkButton><BR /><asp:DropDownList id="rcmbVoucherNumber" runat="server" CssClass="ComboBox" AutoPostBack="True" OnSelectedIndexChanged="rcmbVoucherNumber_SelectedIndexChanged">
                            </asp:DropDownList><asp:ImageButton id="imgVoucherNumber" runat="server" ToolTip="Reset the Filter" ImageUrl="~/Images/action_refresh.gif" OnClick="imgVoucherNumber_Click"></asp:ImageButton>
</HeaderTemplate>
                        <ItemTemplate>
<asp:Label id="VoucherNumberLabel" runat="server" Text='<%# Eval("VoucherNumber") %>' ></asp:Label>
</ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn DataField="DueDate" HeaderText="Due Date" UniqueName="DueDate">
                        <EditItemTemplate>
<asp:TextBox id="DueDateTextBox" runat="server" Text='<%# Bind("DueDate", "{0:dd-MMM-yy}") %>' ></asp:TextBox>
</EditItemTemplate>
                          <HeaderTemplate>
<asp:LinkButton id="lbDueDate" runat="server" CssClass="Link" Text="Due Date" CommandArgument="DueDate" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lbDueDate_Command" BackColor="Transparent"></asp:LinkButton><BR /><asp:DropDownList id="rcmbDueDate" runat="server" CssClass="ComboBox" AutoPostBack="True" OnSelectedIndexChanged="rcmbDueDate_SelectedIndexChanged">
                            </asp:DropDownList><asp:ImageButton id="imgDueDate" onclick="imgDueDate_Click" runat="server" ToolTip="Reset the Filter" ImageUrl="~/Images/action_refresh.gif"></asp:ImageButton>
</HeaderTemplate>
                        <ItemTemplate>
<asp:Label id="DueDateLabel" runat="server" Text='<%# Eval("DueDate", "{0:dd-MMM-yy}") %>'></asp:Label>
</ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn DataField="SubAccountName" HeaderText="Sub Acc Name" UniqueName="SubAccountName">
                        <EditItemTemplate>
<asp:TextBox id="SubAccountNameTextBox" runat="server" Text='<%# Bind("SubAccountName") %>' ></asp:TextBox>
</EditItemTemplate>
                          <HeaderTemplate>
<asp:LinkButton id="lbSubAccountName"  runat="server" CssClass="Link" Text="Sub Acc Name" OnCommand="lbSubAccountName_Command" ForeColor="White" Font-Underline="False" Font-Bold="True" CommandArgument="SubAccountName" BackColor="Transparent" ></asp:LinkButton><BR /><asp:DropDownList id="rcmbSubAccountName" runat="server" CssClass="ComboBox" AutoPostBack="True" Width="150px" OnSelectedIndexChanged="rcmbSubAccountName_SelectedIndexChanged" >
                            </asp:DropDownList><asp:ImageButton id="imgSubAccountName"  runat="server" ToolTip="Reset the Filter" ImageUrl="~/Images/action_refresh.gif" ></asp:ImageButton>
</HeaderTemplate>
                        <ItemTemplate>
<asp:Label id="SubAccountNameLabel" runat="server" Text='<%# Eval("SubAccountName") %>' ></asp:Label>
</ItemTemplate>
                        <HeaderStyle Width="150px" />
                        <ItemStyle Width="150px" />
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn DataField="Amount_FC" HeaderText="Amount" UniqueName="Amount_FC">
                          <HeaderTemplate>
                            <asp:LinkButton ID="lbAmount_FC" runat="server" BackColor="Transparent" CommandArgument="Amount_FC"
                                CssClass="Link" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lbAmount_FC_Command"
                                Text="Amount" ></asp:LinkButton><br />
                            <asp:DropDownList ID="rcmbAmount_FC" runat="server" AutoPostBack="True" CssClass="ComboBox"
                                OnSelectedIndexChanged="rcmbAmount_FC_SelectedIndexChanged">
                            </asp:DropDownList><asp:ImageButton ID="imgAmount_FC" runat="server" ImageUrl="~/Images/action_refresh.gif"
                                OnClick="imgAmount_FC_Click" ToolTip="Reset the Filter" />
                       
</HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Amount_FCLabel" runat="server" Text='<%# Eval("Amount_FC", "{0:###,###,###,###.#0}") %>' ></asp:Label>
                       
</ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn DataField="BalanceAmount" HeaderText="Balance" UniqueName="BalanceAmount">
                        <EditItemTemplate>
                            <asp:TextBox ID="BalanceAmountTextBox" runat="server" Text='<%# Bind("BalanceAmount", "{0:###,###,###,###.#0}") %>'></asp:TextBox>
                       
</EditItemTemplate>
                          <HeaderTemplate>
                            <asp:LinkButton ID="lbBalanceAmount" runat="server" BackColor="Transparent" CommandArgument="BalanceAmount"
                                CssClass="Link" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lbBalanceAmount_Command"
                                Text="Balance"></asp:LinkButton><br />
                            <asp:DropDownList ID="rcmbBalanceAmount" runat="server" AutoPostBack="True" CssClass="ComboBox"
                                OnSelectedIndexChanged="rcmbBalanceAmount_SelectedIndexChanged">
                            </asp:DropDownList><asp:ImageButton ID="imgBalanceAmount" runat="server" ImageUrl="~/Images/action_refresh.gif"
                                OnClick="imgBalanceAmount_Click" ToolTip="Reset the Filter" />
                       
</HeaderTemplate>
                        <ItemTemplate>
                            <asp:Label ID="BalanceAmountLabel" runat="server" Text='<%# Eval("BalanceAmount", "{0:###,###,###,###.#0}") %>'></asp:Label>
                       
</ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn DataField="CurrencyID" HeaderText="Ccy" UniqueName="CurrencyID">
                          <HeaderTemplate>
<asp:LinkButton id="lbCurrencyID" onclick="lbCurrencyID_Click" runat="server" CssClass="Link" Text="Ccy" BackColor="Transparent" CommandArgument="CurrencyID" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lbSettledAmount_Command" ></asp:LinkButton><BR />
<asp:DropDownList id="rcmbCurrencyID" runat="server" CssClass="ComboBox" AutoPostBack="True" OnSelectedIndexChanged="rcmbCurrencyID_SelectedIndexChanged" >
                            </asp:DropDownList><asp:ImageButton id="imgCurrencyID" onclick="imgSettledAmount_Click" runat="server" ImageUrl="~/Images/action_refresh.gif" ToolTip="Reset the Filter" ></asp:ImageButton>
</HeaderTemplate>
                        <ItemTemplate>
<asp:Label id="lblCurrency" runat="server" Text='<%# Eval("CurrencyID") %>' ></asp:Label>
</ItemTemplate>
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn UniqueName="Template1" HeaderText="Amount FC" >
                       <footertemplate>
                       
</footertemplate>
                         <HeaderTemplate>
<asp:LinkButton id="lblAmountFC" runat="server" CssClass="Link" Text="Amount FC" BackColor="Transparent" OnCommand="lblAmountFC_Command" ForeColor="White" Font-Underline="False" Font-Bold="True" CommandArgument="Amount_FC" Enabled="False" ></asp:LinkButton>
</HeaderTemplate>
                        <ItemTemplate>
<radi:RadNumericTextBox id="txtCurrentPayment" runat="server" AutoPostBack="True" Width="100px" CausesValidation="True" DbValue='<%# Eval("CurrentPayment") %>' Culture="English (United States)" LabelCssClass="radLabelCss_Default" OnTextChanged="txtCurrentPayment_TextChanged" >
<IncrementSettings InterceptArrowKeys="False" InterceptMouseWheel="False"></IncrementSettings>

<ClientEvents OnFocus="Focus"></ClientEvents>

<NumberFormat AllowRounding="True" DecimalDigits="3"></NumberFormat>
</radi:RadNumericTextBox> <radi:RadNumericTextBox id="rntExchangeRate" runat="server" Width="100px" Visible="False" Skin="" DbValue='<%# Eval("ExchangeRate") %>' Culture="English (United States)" LabelCssClass="radLabelCss_Default" OnTextChanged="txtCurrentPayment_TextChanged" >
<IncrementSettings InterceptArrowKeys="False" InterceptMouseWheel="False"></IncrementSettings>

<NumberFormat AllowRounding="True" DecimalDigits="3"></NumberFormat>
</radi:RadNumericTextBox>
</ItemTemplate>
                        <HeaderStyle Width="100px" />
                        <ItemStyle Width="100px" />
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="Amount LC"
                        UniqueName="CurrentPayment_BC">
                          <HeaderTemplate>
<asp:LinkButton id="lblAmountLC" runat="server" CssClass="Link" Text="Amount LC" Enabled="False" CommandArgument="Amount_BC" Font-Bold="True" Font-Underline="False" ForeColor="White" OnCommand="lblAmountBC_Command" BackColor="Transparent"></asp:LinkButton>
</HeaderTemplate>
                        <ItemTemplate>
<radi:RadNumericTextBox id="txtCurrentPaymentBC" runat="server" Width="100px" OnTextChanged="txtCurrentPaymentBC_TextChanged" LabelCssClass="radLabelCss_Default" Culture="English (United States)" DbValue='<%# Eval("CurrentPayment") %>' >
<IncrementSettings InterceptArrowKeys="False" InterceptMouseWheel="False"></IncrementSettings>

<NumberFormat AllowRounding="True" DecimalDigits="3"></NumberFormat>
</radi:RadNumericTextBox>
</ItemTemplate>
                    </rad:GridTemplateColumn>
                        <rad:GridTemplateColumn UniqueName="Template2" >
                                                    <ItemTemplate>
<asp:LinkButton id="lbPaythis" onclick="lbPaythis_Click" runat="server" Width="50px" CommandArgument='<%# Bind("PKey") %>' CommandName="Select">Pay this</asp:LinkButton>
</ItemTemplate>
                                        <footerstyle verticalalign="Middle" horizontalalign="Right" wrap="False" />
                                        <HeaderStyle verticalalign="Middle" horizontalalign="Right" wrap="False" />
                                        <ItemStyle horizontalalign="Right" wrap="False" />
                                    </rad:GridTemplateColumn>
                                </Columns>
                                <RowIndicatorColumn Visible="False">
                                    <HeaderStyle Width="20px" />
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn Resizable="False" Visible="False">
                                    <HeaderStyle Width="20px" />
                                </ExpandCollapseColumn>
                <CommandItemTemplate>
                    <table class="MainTable" style="height: 55%" width="100%">
                        <tr>
                            <td align="right" colspan="5" style="width: 95%" valign="top">
                                <asp:Button ID="btnPayAll" runat="server" CssClass="Button" OnClick="btnPayAll2_Click"
                                    Text="Pay All" Width="80px" />
                                &nbsp; &nbsp;
                            </td>
                            <td valign="top">
                                <asp:ImageButton ID="btnSave2" runat="server" BackColor="WhiteSmoke" BorderColor="WhiteSmoke"
                                    BorderStyle="Solid" BorderWidth="3px" CssClass="IconButton" ImageUrl="~/Images/Save.ico"
                                    OnClick="btnSave2_Click" ToolTip="Save" />
                            </td>
                            <td valign="top">
                                <asp:ImageButton ID="btnUndo2" runat="server" BackColor="WhiteSmoke" BorderColor="WhiteSmoke"
                                    BorderStyle="Solid" BorderWidth="3px" ImageUrl="~/Images/Undo.ico" OnClick="btnUndo2_Click"
                                    ToolTip="Undo" />
                            </td>
                        </tr>
                    </table>
                </CommandItemTemplate>
                            </MasterTableView>
                            <ClientSettings AllowKeyboardNavigation="True" >
                                <Selecting AllowRowSelect="True" />
                                <ClientEvents OnActiveRowChanged="ActiveRowChanged"  OnGridCreated="GridCreated" OnActiveRowChanging="ActiveRowChanging" OnRowMouseOver="RowMouseOver" OnRowSelected="RowSelected" />
                            </ClientSettings>
                        </radg:RadGrid>

 

Tags
Grid
Asked by
Manoj
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Vijay Kartha
Top achievements
Rank 1
Share this question
or