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

asp:LinkButton OnRowSelected

2 Answers 51 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 18 Sep 2012, 04:40 AM

<telerik:GridTemplateColumn UniqueName="rdbnot" DataField ="Escalation_Notify_ID" SortExpression="Escalation_Notify_ID" ItemStyle-BorderStyle="None" HeaderText="<%$ Code:Resources.Escalation.Notification_Freq%>">
<ItemStyle Width="150px" BorderStyle="None" HorizontalAlign="Left" />
                                                                                                            <ItemTemplate>                                                                                                           
<asp:LinkButton ID="btnNotify" runat="server" OnClientClick="AddNotify()"></asp:LinkButton>                                                                                                                       
</ItemTemplate>
<ItemStyle Width="150px" BorderStyle="None" HorizontalAlign="Left" />
</telerik:GridTemplateColumn>

link button row select is work in Ie 9, It's Not worked in Mozilla and chroma ,

<ClientSettings AllowRowsDragDrop="True">
<ClientEvents OnRowSelected="RowClicked" />
</ClientSettings>

function RowClicked(sender, eventArgs) {
                rowCounts = grid.get_masterTableView().get_selectedItems().length;
            }
 

Thanks Advance,
Mohamed.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2012, 06:29 AM
Hi,

I am not sure about your requirement. I guess the RowSelected event is not firing since, you are selecting a row using LinkButton in server side. Please check the sample code snippet I tried to fire RowSelected event in on selecting a row on LinkButton Click.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem item1 = (GridDataItem)e.Item;
        LinkButton hyplnk = (LinkButton)item1.FindControl("btnNotify");
        hyplnk.Attributes.Add("OnClick", "return Click('" + item1.ItemIndex + "');");
    }
}

Javascript:
function Click(indx)
{
        var RadGrid2 = $find("<%= RadGrid1.ClientID %>");
        RadGrid2.get_masterTableView().get_dataItems()[indx].set_selected("true");
}
function RowClicked(sender, eventArgs)
{    
   rowCounts = sender.get_masterTableView().get_selectedItems().length;
   alert(rowCounts);
}

Thanks,
Shinu.
0
mohamed
Top achievements
Rank 1
answered on 18 Sep 2012, 06:42 AM
Thanks For Your Reply Shinu,
I Have client Function in that link button ,
if i run it clinet function is run first after that script run ,
how i put that script in that function
function AddNotify(sender, eventArgs) {               
                var RadWindow = $find("<%=rdWInAddNotify.ClientID%>");
                RadWindow.set_title("<%= Resources.CAB.Approvals%>");
 
                var Notify = window.document.getElementById("hdNotify").value;
                var linkid = window.document.getElementById("hdLinkid").value;
                var hdNotifyID = window.document.getElementById("hdNotifyID").value;
 
                var grid = $find("<%=RadgridNotifyPeople.ClientID%>")
                var MasterTable = grid.get_masterTableView();
                var dataItems = MasterTable.get_dataItems();
                var selectedRows = MasterTable.get_selectedItems();
                var row, cell, item;
 
                if (selectedRows != null) {
                    for (var i = 0; i < selectedRows.length; i++) {
                        row = selectedRows[i];
                        item = row.getDataKeyValue("Escalation_Notify_ID");
                        var name1 = row.getDataKeyValue("Escalation_Notify_Name_Display");
                        RadWindow.setUrl("../Escalation/Notify.aspx?id=" + item + "&linkid=" + name1);
                        RadWindow.setSize(450, 170);
                        RadWindow.show();
                    }
                }
            }


Thanks Advance,
Mohamed.
Tags
Grid
Asked by
mohamed
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
mohamed
Top achievements
Rank 1
Share this question
or