• Getting Started
  • Components
    • Barcodes
    • Buttons
    • Chartsupdated
    • Conversational UIupdated
    • Data Query
    • Date Inputsupdated
    • Date Math
    • Dialogs
    • Drawing
    • Dropdownsupdated
    • Editor
    • Excel Export
    • File Saver
    • Filter
    • Gantt
    • Gauges
    • Gridupdated
    • Icons
    • Indicators
    • Inputsupdated
    • Labels
    • Layout
    • ListBox
    • ListView
    • Map
    • Menus
    • Navigation
    • Notification
    • Pager
    • PDF Export
    • PDFViewer
    • PivotGridupdated
    • Popup
    • ProgressBars
    • Ripple
    • Schedulerupdated
    • ScrollView
    • Sortable
    • Spreadsheetupdated
    • ToolBar
    • Tooltips
    • TreeList
    • TreeView
    • Typography
    • Uploads
    • Utilities
  • Styling & Themes
  • Common Features
  • Project Setup
  • Knowledge Base
  • Sample Applications
  • FAQ
  • Troubleshooting
  • Updates
  • Changelogs
New to Kendo UI for Angular? Start a free 30-day trial

toDataSourceRequestString

Converts a DataSourceRequestState into a string that is comparable with the DataSourceRequest format in UI for ASP.NET MVC.

 import {
     toDataSourceRequestString,
     translateDataSourceResultGroups,
     translateAggregateResults
} from '@progress/kendo-data-query';

export class Service {
 private BASE_URL: string = '...';

 constructor(private http: Http) { }

 // Omitted for brevity...

 private fetch(state: DataSourceRequestState): Observable<DataResult> {
  const queryStr = `${toDataSourceRequestString(state)}`; //serialize the state
  const hasGroups = state.group && state.group.length;

  return this.http
      .get(`${this.BASE_URL}?${queryStr}`) //send the state to the server
      .map(response => response.json())
      .map(({Data, Total, AggregateResults}) => // process the response
          (<GridDataResult>{
              //if there are groups convert them to compatible format
              data: hasGroups ? translateDataSourceResultGroups(Data) : Data,
              total: Total,
              // convert the aggregates if such exists
              aggregateResult: translateAggregateResults(AggregateResults)
          })
      );
 }
}

Parameters

state DataSourceRequestState

The state that will be serialized.

Returns

string - The serialized state.

In this article

Not finding the help you need?