/// <summary> /// Gets the DataSource for an individual series. The igDataChart supports defining a single dataSource for all series, or individual data sources for each series. /// If the series does not has a DataSource explicitly defined then this method will return null, and you should call GetDataSource instead. /// </summary> /// <typeparam name="T">The object type for each item in the DataSource.</typeparam> /// <param name="seriesTitle">The title of the series you want to retrieve.</param> /// <returns>The DataSource as an IEnumerable of T.</returns> public IEnumerable <T> GetSeriesDataSource <T>(string seriesTitle) { string scriptString = @"var result; var series = $(arguments[0]).igDataChart('option', 'series'); for (var x = 0; x < series.length; x++) { if (series[x].title == arguments[1] && series[x].hasOwnProperty('dataSource')) { result = series[x].dataSource; break; } } if (result != null) return JSON.stringify(result); else return null;"; scriptString = Regex.Replace(scriptString, @"\t|\n|\r", ""); //I kept the script string in a readable format in the C# code, this line makes it a valid js script format var jsResult = WrappedDriver.ExecuteScript(scriptString, WrappedElement, seriesTitle) as string; IEnumerable <T> dataSource = null; if (jsResult != null) { dataSource = JsonConvert.DeserializeObject <IEnumerable <T> >(jsResult); } return(dataSource); }
/// <summary> /// Scrolls the specified row into view. This method should be used to scroll virtualized grid rows into view before interacting with them. /// </summary> /// <param name="rowIndex">Index of the row.</param> public void ScrollGridRowIntoView(int rowIndex) { //There is a bug where the 'virtualScrollTo' js function won't correctly scroll a row into view, the workaround is to scroll to the first index, wait, then scroll to the real index WrappedDriver.ExecuteScript(@"$(arguments[0]).igGrid('virtualScrollTo', arguments[1]);", WrappedElement, 0); Thread.Sleep(1000); WrappedDriver.ExecuteScript(@"$(arguments[0]).igGrid('virtualScrollTo', arguments[1]);", WrappedElement, rowIndex); }
/// <summary> /// Returns a json array consisting of only the objects that are visible in the grid and in the order they appear (i.e. filtering and sorting is applied). /// </summary> /// <returns></returns> protected string GetDataViewJSON() { string jsText = @"return JSON.stringify($(arguments[0]).data('igGrid').dataSource.dataView());"; return(WrappedDriver.ExecuteScript(jsText, WrappedElement) as string); }