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

RadGrid datasource is null

3 Answers 604 Views
Grid
This is a migrated thread and some comments may be shown as answers.
vinitha
Top achievements
Rank 1
vinitha asked on 30 Mar 2010, 06:57 AM
Hi All,

I am facing a wierd issue. "grid.MasterTableView.get_dataSource()" is null while binding the data on postback in data binding event.

Entire code is in RadWindow.

I am binding data to the RadGrid in "DataBinding" event. In this first i am clearing all the selected items and then binding the data using webservice call. Clearing all the selected items because, when the user selects few records in the first page and navigtes to the next page, the selection is getting retained and few records are selected even in second page. To remove selection, I am keeping the values in the array and marking them selected while navigating. This works perfectly fine.

In RadWindow, i have an 'Apply' button which refreshes the radwindow and binds the data to the radgrid. While executing clearSelectedItems() function, OnRowSelected event is fired and MasterTableView.get_dataSource() is null. Not sure why the datasource is null.

Please help to resolve this.

Thanks,
Vinitha

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 01 Apr 2010, 04:17 PM
Hello Vinitha,

In order to achieve the desired functionality you can use same approach as the following demo:
Grid / Master/Details Client-side Data Binding

Please, give it a try and let me know if it works for you.

Regards,
Pavlina
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.
0
vinitha
Top achievements
Rank 1
answered on 01 Apr 2010, 07:09 PM
Hi,

Thanks for the response.

Actually i have checbox column in my grid, If any row is selected in the first page and user navigates to next page, then the row is selected in that page also which is not required. So we are storing all the required values in an array and clearing all the selectedItems when we are navigating from page to page. Another thing is, to handle "Select All" functionality, i need the datasource count. If i use dataItems.length it gives me the page size but not the datasource size. How can i achieve this?

While doing so, I am getting a javascript error saying "....get_masterTableView().get_dataSource()" is null. Is there any way to get the datasource count instead of using the datasource()? Or do we have any other function or property exposed on sender or args or anything else to give the data source count?

Please do help me in resolving this...

Sending the code snippet.

function

 

<%= ProjectMembersLstGrid.ClientID%>_DataBinding(sender, args)

 

{

var

 

masterTable = sender.get_masterTableView();

 

isChkRem =

true;

 

masterTable.clearSelectedItems();

 

var methodArgs = args.get_methodArguments();

 

 

 

var projectId = Number($('<%=hdnProjectId.ClientID %>').value);

 

 

if(projectId > 0)

 

methodArgs.projectId = projectId;

 

 

if(methodArgs.sortExpression != null && (methodArgs.sortExpression[0] == null || methodArgs.sortExpression[0] == undefined))

 

{

 

var gridSortRender = new GridSort.GridSortRender();

 

gridSortRender.SetSortIconOnGridColumn(

"PersonName", $find("<%=ProjectMembersLstGrid.ClientID %>"));

 

}

 

args.set_methodArguments(methodArgs);

 

var serviceUrl = args.get_location().replace(/[~/. ]/gi,"$").toLowerCase();

 

 

if (window.$WebServiceKeys)

 

{

 

if($WebServiceKeys[serviceUrl])

 

webServiceKey = $WebServiceKeys[serviceUrl];

}

 

// Querystring arguments must be appended to the webservice method name.

 

args.set_methodName(

"GetProjectMembersAssociatedToProject?WebServiceKey=" + webServiceKey);

 

}


 

function

 

ProjectMembersOnRowSelected(sender, args)

 

{


// remove the wrong data that gets added to selecteditems array when select all check box is checked.

 

if(sender.get_masterTableView().get_selectedItems().length > $find('<%= ProjectMembersLstGrid.ClientID %>').MasterTableView.get_dataSource().length)

 

{

isPrjExtraData =

true;

 

sender.get_masterTableView().get_selectedItems()[sender.get_masterTableView().get_selectedItems().length - 1].set_selected();

 

return;

 

}

In ProjectMembersOnRowSelected function above is called when clearSelectedItems() is called in _DataBinding function and  get_dataSource() is null.

Not sure why this is null..

Please help me in resolving this..

0
Pavlina
Telerik team
answered on 02 Apr 2010, 02:55 PM
Hi Vinitha,

Could you please attach a simple project illustrating this issue to a formal support ticket? We need to investigate this behavior locally and afterward we will be able to give more straight-to-the-point answer.
Thank you for your cooperation!

Best wishes,
Pavlina
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
vinitha
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
vinitha
Top achievements
Rank 1
Share this question
or