public void TestProviderMetadataType() { var pi = typeof(TestGridAnnotationModel).GetProperty("Title"); var opt = _provider.GetAnnotationForColumn <TestGridAnnotationModel>(pi); Assert.IsNotNull(opt); Assert.AreEqual(opt.Title, "Some title"); //ensure that title reads from metadata type class var gridSettings = _provider.GetAnnotationForTable <TestGridAnnotationModel>(); Assert.IsNotNull(gridSettings); Assert.AreEqual(gridSettings.PageSize, 20); Assert.AreEqual(gridSettings.PagingEnabled, true); }
public void TestProviderMetadataType() { var pi = typeof(TestGridAnnotationModel).GetProperty("Title"); var opt = _provider.GetAnnotationForColumn <TestGridAnnotationModel>(pi); PAssert.IsTrue(() => opt != null); PAssert.IsTrue(() => opt.Title == "Some title"); //ensure that title reads from metadata type class var gridSettings = _provider.GetAnnotationForTable <TestGridAnnotationModel>(); PAssert.IsTrue(() => gridSettings != null); PAssert.IsTrue(() => gridSettings.PageSize == 20); PAssert.IsTrue(() => gridSettings.PagingEnabled); }
/// <summary> /// Applies data annotations settings /// </summary> private void ApplyGridSettings() { GridTableAttribute opt = _annotations.GetAnnotationForTable <T>(); if (opt == null) { return; } EnablePaging = opt.PagingEnabled; if (opt.PageSize > 0) { Pager.PageSize = opt.PageSize; } if (opt.PagingMaxDisplayedPages > 0 && Pager is GridPager) { (Pager as GridPager).MaxDisplayedPages = opt.PagingMaxDisplayedPages; } }