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

Client side Problem in RadGrid

2 Answers 75 Views
Grid
This is a migrated thread and some comments may be shown as answers.
AMS
Top achievements
Rank 1
AMS asked on 20 Sep 2010, 02:04 PM
Hi
I am using the same method for binding data returned from json to the client side.
Please note that i am using this Grid in asp.net MVC 1.0. Script Manager and all other telerik objects are loading properly and i am receiving this JSON from a method which returns JSON. I hope that the given code is sufficient, however i can provide you MVC code, if required:
I am using the following code:

$.ajax({
            type: "POST",
            url: getAppPath() + "Account.aspx/UsersList",
            data: { State: StateVal, County: CountyVal, District: DistrictVal, School: SchoolVal, sUserName: userName, sUserEmail: email, Status: StatusVal },
            success: function(results) {
                //alert(results);
                updateGrid(results);
            },
            error: function(msg) {
                alert("The following error occurred: " + msg.status + ": " + msg.statusText);
            }

        });

 <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">
           

            function updateGrid(result) {
                var tableView = $find("<%= grdUsers.ClientID %>").get_masterTableView();
                tableView.set_dataSource(result);
                tableView.dataBind();
            }

            function RadGrid1_Command(sender, args) {
                
                var a = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
                args.set_cancel(true);
                alert("page command");

            }


        
    
        </script>

    </telerik:RadCodeBlock>

When i call the updateGrid method
                var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView();
the following line returns null. However if i only use this line, it will find the Grid.
var a = $find("<%= RadGrid1.ClientID %>")
Please let me know how to handle it and later assign the json to grid in order to populate it.
Thanks.

2 Answers, 1 is accepted

Sort by
0
AMS
Top achievements
Rank 1
answered on 21 Sep 2010, 12:02 PM
I have gone through this post

http://www.telerik.com/community/forums/aspnet-ajax/grid/client-side-databinding-itemdatabound-firing-before-grid-is-bound.aspx

if i declare the OnCommand event of grid in order to initialize it like this, i am getting the following error

Control 'ctl00_MainContent_RadGrid1_ctl00_ctl02_ctl01_ctl04' of type 'Button' must be placed inside a form tag with runat=server.


function RadGrid1_Command(sender, args) { } //for initializing grid on client side
 
 <telerik:RadGrid ID="RadGrid1" runat="server" Skin="Web20" AutoGenerateColumns="false"
            AllowPaging="true">
            <MasterTableView TableLayout="Fixed">
                <Columns>
                    <telerik:GridBoundColumn DataField="Username" HeaderText="User Name" />
                    <telerik:GridBoundColumn DataField="Email" HeaderText="Email" />
                </Columns>
            </MasterTableView>
           <ClientSettings>
                <ClientEvents  OnCommand="RadGrid1_Command" />
            </ClientSettings>
        </telerik:RadGrid>
0
Radoslav
Telerik team
answered on 23 Sep 2010, 10:52 AM
Hello Abbid,

To achieve the desired functionality and avoid the described error I suggest you to use the Telerik Grid for ASP.NET MVC instead of RadGrid for ASP.NET Ajax. On the following link you could find the online demos for the ASP.NET MVC grid:
http://demos.telerik.com/aspnet-mvc/grid

Best wishes,
Radoslav
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
AMS
Top achievements
Rank 1
Answers by
AMS
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or