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

update panel for a row in a grid

3 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Yu
Top achievements
Rank 1
Yu asked on 18 Nov 2010, 04:29 PM
Hi There,

Just a quick question: is it possible to put a grid row in an update panel and set up triggers/server side event handler for the panel?

I would like the following feature: if postback is triggered by a grid row, i.e., a dropdown list with autopostback enabled, only elements in the grid row will be re-rendered and go to the client side (browser).

Thanks,
Y. Fan

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 19 Nov 2010, 08:02 AM
Hello,


One suggestion is invoking ajaxRequest() from client side to update the control in same row. Pass the row index to the client side event handler of DropDownList and get the corresponding GridItem client object. Now use the findControl()/findElement() to get  reference to the control placed in the row.



-Shinu.
0
Yu
Top achievements
Rank 1
answered on 19 Nov 2010, 10:30 PM
Thanks for your reply.  2 questions again:

 1) How can I get the row that is being changed? for example:
<telerik:GridTemplateColumn UniqueName="Date" DataField="Date" HeaderText="Date">
    <ItemTemplate>
        <telerik:RadDatePicker ID="rdpDate" runat="server" MaxLength="10" Visible="true" DateInput-DateFormat="dd/MMM/yyyy" >
            <ClientEvents OnDateSelected="GridRow_DateChanged" />
        </telerik:RadDatePicker>
    </ItemTemplate>
</telerik:GridTemplateColumn>
As we see the client event handler "GridRow_DataChanged" will be automatically wired up with the arguments "sender" and "args".Now sender is the RadDatePicker "rdpDate" and sender.get_parent() is the whole grid, but how can I get the row that is being changed? I tried to use "getCellByUniqueName" to get each element in the row but I was asked to provide the row index or the row itself... how can I know the row index, especially, for the new line (inserted item)?

2) If using ajaxRequest, should I handle the data returned and if so what type of data ajaxRequest returns? I used to use ajax $.post and I can set up the data type (json or something else) that $.post returns. Can I do it in ajaxRequest like that in ajax $.post?

Thanks again in advance,

Y.Fan
0
Nikolay Rusev
Telerik team
answered on 25 Nov 2010, 11:51 AM
Hello Yu,

Bellow is the script that you can use to find corresponding GridDataItem on client-side:
<telerik:RadScriptBlock runat="server">
        <script type="text/javascript">
            function pageLoad()
            {
                var grid = $find('<%=Grid.ClientID %>');
                grid.get_masterTableView().get_dataItems();
            }
  
            function GridRow_DateChanged(sender, args)
            {                
                var row = Telerik.Web.UI.Grid.GetFirstParentByTagName(sender.get_element(), "TR");
                var dataItem = $find(row.id);
            }
        </script>
    </telerik:RadScriptBlock>

Regarding the second part of your questions: arguments are send on server as string and you can parse them. More details on the article bellow:
http://www.telerik.com/help/aspnet-ajax/ajxonajaxrequest.html

Greetings,
Nikolay
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Yu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Yu
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or