/// <summary>
 /// Forces DataTables to use CamelCase on request/respose parameter names.
 /// CamelCase is enabled by default and is available for DataTables 1.10 and above.
 /// </summary>
 /// <returns></returns>
 public IOptions UseCamelCase()
 {
     RequestNameConvention = new CamelCaseRequestNameConvention(); ResponseNameConvention = new CamelCaseResponseNameConvention(); return(this);
 }
Beispiel #2
0
 public GridModelBinder()
 {
     _requestConvention = new CamelCaseRequestNameConvention();
 }
Beispiel #3
0
        private static IEnumerable <Sort> ParseSorting(IEnumerable <Column> columns, IValueProvider values, CamelCaseRequestNameConvention names)
        {
            var sorting = new List <Sort>();

            for (int i = 0; i < columns.Count(); i++)
            {
                var sortField  = values.GetValue(String.Format(names.SortField, i));
                int _sortField = 0;
                if (!Parse <int>(sortField, out _sortField))
                {
                    break;
                }

                var column = columns.ElementAt(_sortField);

                var    sortDirection  = values.GetValue(String.Format(names.SortDirection, i));
                string _sortDirection = null;
                Parse <string>(sortDirection, out _sortDirection);

                if (column.SetSort(i, _sortDirection))
                {
                    sorting.Add(column.Sort);
                }
            }

            return(sorting);
        }
Beispiel #4
0
        private static IEnumerable <Column> ParseColumns(IValueProvider values, CamelCaseRequestNameConvention names)
        {
            var columns = new List <Column>();

            int counter = 1;

            while (true)
            {
                // Parses Field value.
                var    columnField  = values.GetValue(String.Format(names.ColumnField, counter));
                string _columnField = null;
                if (!Parse(columnField, out _columnField))
                {
                    break;
                }

                // Parses Name value.
                var    columnName  = values.GetValue(String.Format(names.ColumnName, counter));
                string _columnName = null;
                if (!Parse(columnName, out _columnName))
                {
                    break;
                }

                // Parses Orderable value.
                var  columnSortable  = values.GetValue(String.Format(names.IsColumnSortable, counter));
                bool _columnSortable = true;
                Parse(columnSortable, out _columnSortable);

                // Parses Searchable value.
                var columnSearchable  = values.GetValue(String.Format(names.IsColumnSearchable, counter));
                var _columnSearchable = true;
                Parse(columnSearchable, out _columnSearchable);

                // Parsed SearchQuery value.
                var    columnSearchValue  = values.GetValue(String.Format(names.ColumnSearchValue, counter));
                string _columnSearchValue = null;
                Parse(columnSearchValue, out _columnSearchValue);

                // Parses IsRegex value.
                var  columnSearchRegex  = values.GetValue(String.Format(names.IsColumnSearchRegex, counter));
                bool _columnSearchRegex = false;
                Parse(columnSearchRegex, out _columnSearchRegex);

                var search = new SearchQuery()
                {
                    Value   = _columnSearchValue,
                    IsRegex = _columnSearchRegex
                };

                var column = new Column()
                {
                    ColumnField  = _columnField,
                    Name         = _columnName,
                    IsSearchable = _columnSearchable,
                    IsSortable   = _columnSortable,
                    SearchQuery  = search
                };

                columns.Add(column);

                counter++;
            }

            return(columns);
        }