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

CALL RowClick(sender, eventArgs) Function on Link Button/Urgent

3 Answers 173 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradeep
Top achievements
Rank 1
pradeep asked on 11 Oct 2011, 08:17 AM
Hello Sir,

Please provide me Help .

I want to call  function RowClick(sender, eventArgs) on Simple Link Buttton  not  to call <ClientEventsOnRowClick="RowClick" OnRowDblClick="RowDblClick"  OnGridCreated="GridCreated" OnCommand="GridCommand"   />


My code is details on   below.
  <script type="text/javascript">
        <!--
            var hasChanges, inputs, dropdowns, editedRow;

            function RowClick(sender, eventArgs) {

               
                 var a;
                var aa;
                var gridElement = sender.get_element();
                
                inputs = gridElement.getElementsByTagName("input");
                for (var i = 0; i < inputs.length; i++) {
                    var lowerType = inputs[i].type.toLowerCase();
                    if (lowerType == "text") {
                        a = inputs[i].id
                        aa = document.getElementById(a).value;
                    }

                }
                // alert("awanish");
                if (editedRow && hasChanges) {
                    alert('a');
                    hasChanges = false;
                    if (confirm("Update changes?")) {

                        PageMethods.fneditData(a, aa, editedRow, OnGetMessageSuccess, OnGetMessageFailure);
                        $find("<%= grdT101.MasterTableView.ClientID %>").updateItem(editedRow);
                    }
                }
            }
            function GetMessage() {

                PageMethods.Message(OnGetMessageSuccess, OnGetMessageFailure);

            }
            function OnGetMessageSuccess(result, userContext, methodName) {
                window.location = window.location;
                //////                
            }

            function OnGetMessageFailure(error, userContext, methodName) {

                alert(error.get_message());

            }
            function RowDblClick(sender, eventArgs) {
                editedRow = eventArgs.get_itemIndexHierarchical();
                $find("<%= grdT101.MasterTableView.ClientID %>").editItem(editedRow);
            }

            function GridCommand(sender, args) {
                if (args.get_commandName() != "Edit") {
                    editedRow = null;
                }
            }

            function GridCreated(sender, eventArgs) {
                var gridElement = sender.get_element();
                var elementsToUse = [];
                inputs = gridElement.getElementsByTagName("input");
                for (var i = 0; i < inputs.length; i++) {
                    var lowerType = inputs[i].type.toLowerCase();
                    if (lowerType == "hidden" || lowerType == "button") {
                        continue;
                    }

                    Array.add(elementsToUse, inputs[i]);
                    inputs[i].onchange = TrackChanges;
                }

                dropdowns = gridElement.getElementsByTagName("select");
                for (var i = 0; i < dropdowns.length; i++) {
                    dropdowns[i].onchange = TrackChanges;
                }

                //setTimeout(function() { if (elementsToUse[0]) elementsToUse[0].focus(); }, 100);
            }

            function TrackChanges(e) {
                hasChanges = true;
            }
     -->    
    </script>

<telerik:RadGrid runat="server" ID="grdT101"  Skin="Office2007"
            AutoGenerateColumns="false"   OnRowDrop="grdPendingOrders_RowDrop"
              AllowPaging="True"   AllowMultiRowSelection="true" BorderWidth="0"
            Width="100%"  PageSize="30" EnableHeaderContextMenu="true"  
            GridLines="Both"  onitemcommand="grdT101_ItemCommand" AllowAutomaticUpdates="True" >
                <%--<ItemStyle BackColor="#ffffff" />
                <HeaderStyle BackColor="#ffffff" />--%>                
                <MasterTableView DataKeyNames="T101_ID"  EditMode="InPlace" Width="100%"  >
                    <Columns>
                        <%--<telerik:GridBoundColumn HeaderText="ID"  ReadOnly="True" DataField="T201_ID" HeaderStyle-Width="3%"  />--%>
                        <telerik:GridTemplateColumn HeaderStyle-Width="3%" HeaderText="ID" HeaderStyle-Font-Bold="true" >

<ItemTemplate>

<%#Container.ItemIndex+1 %>

</ItemTemplate>

</telerik:GridTemplateColumn>

                        <telerik:GridBoundColumn  HeaderText="Act Exp(T101 - C101A)" DataField="C101A" HeaderStyle-Font-Bold="true" HeaderStyle-Width="94%"  ItemStyle-Width="94%" UniqueName="C101A" />
<telerik:GridTemplateColumn HeaderStyle-Width="3%">
<ItemTemplate>
<asp:LinkButton ID="cxc" runat="server" CommandArgument='<%#Eval("T101_ID") %>' CommandName="DeleteRow"  OnClientClick="if(!confirm('Are you sure to delete this record ?'))return false;" ><img src="../../images/delete.gif" /></asp:LinkButton>
  <asp:LinkButton ID="lnkbutton" runat="server" Text="LinkButton" CommandName="RowClick"></asp:LinkButton>
</ItemTemplate>
</telerik:GridTemplateColumn>

</Columns>
<CommandItemTemplate>
<asp:TextBox ID="txtC101A" runat="server"></asp:TextBox>
</CommandItemTemplate>
 </MasterTableView>
                <ClientSettings  AllowRowsDragDrop="True" AllowColumnsReorder="true" ReorderColumnsOnClient="true">
                    <Resizing AllowColumnResize="true" />
                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="false"/>
                    <ClientEvents OnRowDropping="onRowDropping" OnRowClick="RowClick" OnRowDblClick="RowDblClick"
                    OnGridCreated="GridCreated" OnCommand="GridCommand"   />
                    <Scrolling  UseStaticHeaders="true"/>                   
                </ClientSettings>
                <PagerStyle Mode="NumericPages" PageButtonCount="4" />
            </telerik:RadGrid>


Please Provide help It is very-2 urgent

Your support will be highly appreciated.

Thank You,

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Oct 2011, 10:33 AM
Hello Pradeep,

You can achieve this functionality by attaching the client side click event to LinkButton in ItemCreated event and pass the index to handler.Also set the Selecting-AllowRowSelect property in ClientSettings to true.Here is the code.

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
  if (e.Item is GridDataItem)
    {
     GridDataItem item = (GridDataItem)e.Item;
     LinkButton btn = (LinkButton)item.FindControl("LinkButton5");
     btn.Attributes.Add("onclick", "LinkButtonClick('" + e.Item.ItemIndex + "');return false");
    }
}

JS:
<script type="text/javascript">
 function LinkButtonClick(index)
{
  var grid = $find("<%=advancedgrid.ClientID %>");
  var MasterTable = grid.get_masterTableView();
  var row = MasterTable.get_dataItems()[index];
  row.set_selected(true);
}
</script>

Thanks,
Shinu.
0
gc_0620
Top achievements
Rank 1
answered on 22 Oct 2014, 08:58 PM
Hi Shinu,
My situation is opposite. I have a hidden radbutton; I would like to call that button from JavaScript. Basically I would like to run the button click event from javascript.

<telerik:RadButton ID="RadButton1" Visible="false" runat="server" Text="RadButton">
</telerik:RadButton>

Thanks
0
Eyup
Telerik team
answered on 27 Oct 2014, 11:59 AM
Hello Ghulam,

Please note that when the Visible property is disabled, the control is not rendered on the client-side at all and thereby, it does not have a javascript object. Instead, you can use the following approach:
<telerik:RadButton ... Style="display: none;">
JavaScript:
function someAction() {
    $find('<%= RadButton1.ClientID %>').click();
}

Hope this helps. Please give it a try and let me know if it works for you.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
pradeep
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
gc_0620
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or