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

Rebinding RadGrid using Javascript

3 Answers 242 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 21 Dec 2012, 12:41 PM

I am trying to rebind my RadGrid after I have performd some actions below is my ajax code that does some operations in server side:

var id = $(this).find("input[name$=hiddenID]").val();

                 $.ajax({
                    type: "POST",
                    url: "Details.aspx/DoStuff",
                    data: "{'id': '" + id + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",

                    success: function (msg) {
                        if (msg.d == 'Sent') {
                            $.colorbox({ href: '/view.aspx?Id=' + id, iframe: true,});
                           GridRebind();
                        }
                    }

                });

To rebind on success I have got this javascript code:

function GridRebind() {
                        var masterTable = $find("<%= gd.ClientID %>").get_masterTableView();
                        masterTable.rebind();
                    }

But everytime I get $find(..)is null on var masterTable = $find("<%= gd.ClientID %>").get_masterTableView(); and it doesn't rebind the grid.

When researching I found out you need to put the following in Grid and set Grid datasource to something on page Init but still not working :

 <ClientSettings>
      <ClientEvents OnCommand="function(){}"  />
 </ClientSettings>

3 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 26 Dec 2012, 08:17 AM
Hi Sam,

I was not able to reproduce this issue. I prepared a small sample where you could see that rebind functionality works properly. Could you please elaborate a little bit more on your scenario? How my sample project differs from your real setup?

All the best,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sam
Top achievements
Rank 1
answered on 02 Jan 2013, 09:39 AM
Hi Kostadin,

Forgot to mention that I am using the grid inside Jquery Tabs(http://jqueryui.com/tabs/). Also am using an older version of Telerik controls, see the attached image for Telerik version, don't know if this makes any difference as in why the grid cannot be found.

To further explain my issue i have master and child view on grid when i click a button on the child I invoke the jquery, if i refresh the tab then the grid will not hold its state(expanded child)... that is why i need to rebind the grid...

PS on your project you have used 
WebUserControl.ascx where can i find that?




0
Kostadin
Telerik team
answered on 04 Jan 2013, 10:43 AM
Hello Sam,

I am still not able to replicate the issue on my side. I modified the sample from my previous post and attached it again. I did not use WebUserControl.ascx anywhere in the example so you could ignore it. Could you please try it again and if you still encounter the same behavior, could you please provide us with your code declaration and the related code behind?

Regards,
Kostadin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Sam
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Sam
Top achievements
Rank 1
Share this question
or