I am client-side binding a RadGrid and can't get it to show my results?
The JavaScript function below does get the results correctly (I know because I step into it and the results are there)
The results is a dictionary - see code behind code below...
But I can't get it to show the results in the grid??
help
JavaScript
RadGrid
Codebehind method
The JavaScript function below does get the results correctly (I know because I step into it and the results are there)
The results is a dictionary - see code behind code below...
But I can't get it to show the results in the grid??
help
JavaScript
| function updateGridCred(result) { |
| var masterTable = $find("<%= gridCred.ClientID %>").get_masterTableView(); |
| masterTable.set_virtualItemCount(result); |
| masterTable.clearSelectedItems(); |
| masterTable.set_dataSource(result); |
| masterTable.dataBind(); |
| $('#divCred').show(); |
| } |
RadGrid
| <telerik:RadGrid ID="gridCred" runat="server" |
| AllowSorting="true" |
| AutoGenerateColumns="false" |
| Width="381" |
| > |
| <ItemStyle Wrap="false" /> |
| <MasterTableView |
| TableLayout="Fixed" |
| AllowAutomaticDeletes="true" |
| EnableColumnsViewState="false" |
| ClientDataKeyNames="CredentialOrganizationId" |
| DataKeyNames="CredentialOrganizationId" |
| > |
| <Columns> |
| <telerik:GridBoundColumn DataField="OrganizationType" UniqueName="OrganizationType" HeaderText="Type"> |
| <HeaderStyle Width="25px" HorizontalAlign="Center" /> |
| <ItemStyle Width="25px" HorizontalAlign="Center" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="OrganizationName" UniqueName="OrganizationName" HeaderText="Organization Name" /> |
| <telerik:GridBoundColumn DataField="DistrictName" UniqueName="DistrictName" HeaderText="District" /> |
| <telerik:GridClientDeleteColumn ConfirmText="Are you sure you want to delete the selected row?" HeaderStyle-Width="35px" ButtonType="ImageButton" /> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings> |
| <DataBinding |
| EnableCaching="false" |
| Location="UserAdmin.aspx" |
| SelectMethod="GetCredentialsAndCount" |
| CountPropertyName="Count" |
| DataPropertyName="Data" |
| StartRowIndexParameterName="startRowIndex" |
| MaximumRowsParameterName="maximumRows" |
| FilterParameterType="Linq" |
| FilterParameterName="filterExpression" |
| SortParameterType="Linq" |
| SortParameterName="sortExpression" |
| /> |
| <Selecting AllowRowSelect="true" /> |
| <ClientEvents OnCommand="gridCred_OnCommand" OnRowSelected="gridCred_CredSelected" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
Codebehind method
| [WebMethod] |
| public static Dictionary<string, Object> GetCredentialsAndCount(int startRowIndex, int maximumRows, string sortExpression, string filterExpression, string CredentialId) |
| { |
| var page = new Apps_UserAdmin(); |
| var dc = page.PageCachedContext.DC; |
| var filter = !String.IsNullOrEmpty(filterExpression); |
| var sort = !String.IsNullOrEmpty(sortExpression); |
| var credId = CredentialId; |
| // have to instantiate the object because static |
| var query = (from co in dc.CredentialOrganizations |
| join tsch in dc.Schools on co.OrganizationId equals tsch.OrganizationId |
| into tschs |
| from s in tschs.DefaultIfEmpty() |
| where co.CredentialId == Convert.ToInt64(credId) |
| orderby co.Organization.Type, s.District.Organization.Name, co.Organization.Name |
| select new |
| { |
| DistrictName = s.District.Organization.Name, |
| OrganizationType = co.Organization.Type, |
| CredentialId = co.CredentialId, |
| CredentialOrganizationId = co.CredentialOrganizationId, |
| OrganizationName = co.Organization.Name, |
| ImageType = ((PinnacleEnums.OrganizationType)Enum.ToObject(typeof(PinnacleEnums.OrganizationType), Convert.ToInt32(co.Organization.Type))).ToString(), |
| }); |
| if (filter) |
| { |
| query = query.Where(filterExpression); |
| } |
| if (sort) |
| { |
| query = query.OrderBy(sortExpression); |
| } |
| var count = query.Count(); |
| var finalItems = query.Skip(startRowIndex).Take(maximumRows); |
| return new Dictionary<string, object> { { "Data", finalItems }, { "Count", count } }; |
| } |