<commit_before>﻿using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Web.Routing;
using System.Web.Script.Serialization;
using Mvc.JQuery.Datatables.Models;
using Mvc.JQuery.Datatables.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Mvc.JQuery.Datatables
{
    public class DataTableConfigVm
    {
        public bool HideHeaders { get; set; }
        IDictionary<string, object> m_JsOptions = new Dictionary<string, object>();

        static DataTableConfigVm()
        {
            DefaultTableClass = "table table-bordered table-striped";
        }

        public static string DefaultTableClass { get; set; }
        public string TableClass { get; set; }

        public DataTableConfigVm(string id, string ajaxUrl, IEnumerable<ColDef> columns)
        {
            AjaxUrl = ajaxUrl;
            this.Id = id;
            this.Columns = columns;
            this.ShowSearch = true;
            this.ShowPageSizes = true;
            this.TableTools = true;
            ColumnFilterVm = new ColumnFilterSettingsVm(this);
            AjaxErrorHandler = 
                "function(jqXHR, textStatus, errorThrown)" + 
                "{ " + 
                    "window.alert('error loading data: ' + textStatus + ' - ' + errorThrown); " + 
                    "console.log(arguments);" + 
                "}";
        }

        public bool ShowSearch { get; set; }

        public string Id { get; private set; }

        public string AjaxUrl { get; private set; }

        public IEnumerable<ColDef> Columns { get; private set; }

        public IDictionary<string, object> JsOptions { get { return m_JsOptions; } }

       

        public string ColumnDefsString
        {
            get
            {
                return ConvertColumnDefsToJson(Columns.ToArray());
            }
        }
        public bool ColumnFilter { get; set; }

        public ColumnFilterSettingsVm ColumnFilterVm { get; set; }

        public bool TableTools { get; set; }

        public bool AutoWidth { get; set; }

        public JToken SearchCols
        {
            get
            {
                var initialSearches = Columns
                    .Select(c => c.Searchable & c.SearchCols != null ? c.SearchCols : null as object).ToArray();
                return new JArray(initialSearches);
            }
        }



        public string Dom
        {
            get { 
                var sdom = "";
                if (ColVis) sdom += "C";
                if (TableTools) sdom += "T<\"clear\">";
                if (ShowPageSizes) sdom += "l";
                if (ShowSearch) sdom += "f";
                sdom += "tipr";
                return sdom;
            }
        }

        public bool ColVis { get; set; }

        public string ColumnSortingString
        {
            get
            {
                return ConvertColumnSortingToJson(Columns);
            }
        }

        public bool ShowPageSizes { get; set; }

        public bool StateSave { get; set; }

        public string Language { get; set; }

        public string DrawCallback { get; set; }
        public LengthMenuVm LengthMenu { get; set; }
        public int? PageLength { get; set; }
        public string GlobalJsVariableName { get; set; }

        private bool _columnFilter;<commit_msg>Add option to use custom DOM<commit_after>﻿using System.Collections.Generic;
using System.Linq;
using System.Net.Mime;
using System.Web.Routing;
using System.Web.Script.Serialization;
using Mvc.JQuery.Datatables.Models;
using Mvc.JQuery.Datatables.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;

namespace Mvc.JQuery.Datatables
{
    public class DataTableConfigVm
    {
        public bool HideHeaders { get; set; }
        IDictionary<string, object> m_JsOptions = new Dictionary<string, object>();

        static DataTableConfigVm()
        {
            DefaultTableClass = "table table-bordered table-striped";
        }

        public static string DefaultTableClass { get; set; }
        public string TableClass { get; set; }

        public DataTableConfigVm(string id, string ajaxUrl, IEnumerable<ColDef> columns)
        {
            AjaxUrl = ajaxUrl;
            this.Id = id;
            this.Columns = columns;
            this.ShowSearch = true;
            this.ShowPageSizes = true;
            this.TableTools = true;
            ColumnFilterVm = new ColumnFilterSettingsVm(this);
            AjaxErrorHandler = 
                "function(jqXHR, textStatus, errorThrown)" + 
                "{ " + 
                    "window.alert('error loading data: ' + textStatus + ' - ' + errorThrown); " + 
                    "console.log(arguments);" + 
                "}";
        }

        public bool ShowSearch { get; set; }

        public string Id { get; private set; }

        public string AjaxUrl { get; private set; }

        public IEnumerable<ColDef> Columns { get; private set; }

        public IDictionary<string, object> JsOptions { get { return m_JsOptions; } }

       

        public string ColumnDefsString
        {
            get
            {
                return ConvertColumnDefsToJson(Columns.ToArray());
            }
        }
        public bool ColumnFilter { get; set; }

        public ColumnFilterSettingsVm ColumnFilterVm { get; set; }

        public bool TableTools { get; set; }

        public bool AutoWidth { get; set; }

        public JToken SearchCols
        {
            get
            {
                var initialSearches = Columns
                    .Select(c => c.Searchable & c.SearchCols != null ? c.SearchCols : null as object).ToArray();
                return new JArray(initialSearches);
            }
        }



        private string _dom;

        public string Dom
        {
            get
            {
                if (!string.IsNullOrEmpty(_dom))
                    return _dom;

                string str = "";
                if (this.ColVis)
                    str += "C";
                if (this.TableTools)
                    str += "T<\"clear\">";
                if (this.ShowPageSizes)
                    str += "l";
                if (this.ShowSearch)
                    str += "f";
                return str + "tipr";
            }

            set { _dom = value; }
        }

        public bool ColVis { get; set; }

        public string ColumnSortingString
        {
            get
            {
                return ConvertColumnSortingToJson(Columns);
            }
        }

        public bool ShowPageSizes { get; set; }

        public bool StateSave { get; set; }

        public string Language { get; set; }

        public string DrawCallback { get; set; }
        public LengthMenuVm LengthMenu { get; set; }
        public int? PageLength { get; set; }
        public string GlobalJsVariableName { get; set; }

        private bool _columnFilter;
{'fraction_non_alphanumeric': 0.08889528193325662, 'fraction_numerical': 0.0, 'mean_word_length': 1.5915020499440924, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6707966', 'n_tokens_mistral': 1905, 'n_tokens_neox': 1811, 'n_words': 477}