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

Problem with client side population - MasterViewTable is null

6 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 19 Feb 2009, 05:00 PM
Hi,

I'm trying to get a grid to load its data from the client side after the parent control has been initialised.

I'm trying to use the set_datasource method to populate the grid with data from a JSON serialised DataTable from a webservice.

I want the grid to create its columns automatically from the datatable if possible.
However, when I call get_masterTableView(), null is returned.

Is what I'm trying to do possible, and if so where am I going wrong?

Thanks in advance.

Regards,
Little Jimi

Code follows:

function performSearch() 
 
    SelectorService.GetData(0,10000000, 
       ... [snip] ..., 
       UpdateGrid, SearchFailed); 
function UpdateGrid(result) 
    var tableView = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
    tableView.set_dataSource(result); 
    tableView.dataBind();                 


        <asp:Panel ID="GridPanel" runat="server" Style="font-size: x-small; clear: both; 
            padding: 4px 2px 2px 2px;" ScrollBars="Auto" Height="200px" Width="444px"
            <Telerik:RadGrid ID="RadGrid1" runat="server" SkinID="Selector" EnableViewState="false" 
                AllowPaging="true" AllowSorting="True" AllowFilteringByColumn="true" GridLines="None" 
                AutoGenerateColumns="true" OnColumnCreated="RadGrid1_ColumnCreated"
                <ClientSettings> 
                    <ClientEvents OnRowSelected="RowSelected" OnRowDblClick="RowDblClick" /> 
                    <Selecting AllowRowSelect="true" EnableDragToSelectRows="true" /> 
                </ClientSettings> 
            </Telerik:RadGrid> 
        </asp:Panel> 

6 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 20 Feb 2009, 04:59 PM
Anyone have any ideas?
If I haven't provided enough information, please let me know.

Cheers.
0
Nikolay Rusev
Telerik team
answered on 20 Feb 2009, 05:23 PM

Hello James,

I am afraid that RadGrid does not support dynamically creation of columns and client-side data-binding.

You should also have in mind that if you are not binding RaGrid on server you should attach  handler to ClientSettings.ClientEvents.OnCommand event.

All the best,
Nikolay
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
PRD
Top achievements
Rank 1
answered on 01 Feb 2011, 05:02 AM
Hi,

In our case we populate the RADGrid in client side using 'set_dataSource(data)' and then 'dataBind()' which works as expected and the grid is populated fine.  However, when we submit the form containing the RADGrid, the items don't seemed to be sent to the server and the myRADGrid.Items.Count shows zero in the server side code behind.

Please let me know if there's something that I might have missed.  If you'd like me to send some code to reproduce the issue then please let me know.  Thanks.
0
Iana Tsolova
Telerik team
answered on 03 Feb 2011, 04:11 PM
Hello,

When the grid is bound client-side you can access its items only on the client as they are created on the client. On the other hand on the server the grid is not bound, just declared and no items are created there.
If you want to manipulate the grid on the server, you need to bind it server-side. Or with the client-side bound grid, you can try using client code to achieve your goal.

Regards,
Iana
the Telerik team
Browse the vast support resources we have to jump start 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.
0
Tim
Top achievements
Rank 1
answered on 03 Oct 2013, 09:29 PM
It will also be null, and the grid's "GridCreated" client-side event will never be fired, if the grid's MasterTableView does not have an "ID" defined.  If your grid was created in the markup of the Page/UserControl, you will have to add Code to the Page/UserControl's "Init" event and set the ID from the code-behind because you are NOT allowed to enter it in markup.  This is probably the root cause of the whole thing, because all other Telerik controls allow you to add the ID property in markup (take the RadDatePicker.DateInput control for example).
0
Tim
Top achievements
Rank 1
answered on 03 Oct 2013, 09:30 PM
It will also be null, and the grid's "GridCreated" client-side event will never be fired, if the grid's MasterTableView does not have an "ID" defined.  If your grid was created in the markup of the Page/UserControl, you will have to add Code to the Page/UserControl's "Init" event and set the ID from the code-behind because you are NOT allowed to enter it in markup.  This is probably the root cause of the whole thing, because all other Telerik controls allow you to add the ID property in markup (take the RadDatePicker.DateInput control for example).
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Nikolay Rusev
Telerik team
PRD
Top achievements
Rank 1
Iana Tsolova
Telerik team
Tim
Top achievements
Rank 1
Share this question
or