Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        /// <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;
            }
        }