Exemple #1
0
        /// <summary>
        /// Constructor. Note. The column specifications must be defined via the DatatableSettings constructor
        /// </summary>
        /// <param name="id">HTML field ID for the Datatable</param>
        /// <param name="settings">Datatable settings</param>
        /// <param name="records">Datatable records</param>
        /// <param name="postbacks">[Optional] Postback data for server side processing</param>
        /// <param name="enableStatusColumn">[Optional] flag indicating whether to enable status column. Defaults to false</param>
        public Datatable(string id, DatatableSettings settings, DatatableRecords records, IEnumerable <PostbackItem> postbacks = null, bool enableStatusColumn = false)
        {
            if (settings.aoColumns == null)
            {
                throw new NullReferenceException("Column setup not done. DatatableSettings.aoColumns property must be set in order to compose the datatable");
            }

            ID        = id.Replace("-", "_");
            Settings  = settings;
            Records   = records;
            Postbacks = postbacks != null?postbacks.ToArray() : new PostbackItem[0];

            EnableStatusColumn = enableStatusColumn;

            if (EnableStatusColumn)
            {
                settings.aoColumns = settings.aoColumns.Concat(new[] { new AOColumn {
                                                                           bVisible = false
                                                                       } }).ToArray();
                settings.SetupfnCreatedRow();
            }

            settings.SetupfnServerData(Postbacks);
        }
Exemple #2
0
        ///// <summary>
        ///// Constructor
        ///// </summary>
        ///// <param name="settings">Datatable settings</param>
        ///// <param name="columns">Datatable column specifications</param>
        ///// <param name="records">Datatable records</param>
        ///// <param name="postbacks">[Optional] Postback data for server side processing</param>
        ///// <param name="enableStatusColumn">[Optional] flag indicating whether to enable status column. Defaults to false</param>
        //[Obsolete("Use Ctor(settings, records, postbacks, enableStatusColumn) instead")]
        //public Datatable(DatatableSettings settings, IEnumerable<DatatableColumn> columns,
        //  DatatableRecords records, IEnumerable<PostbackItem> postbacks = null, bool enableStatusColumn = false)
        //  : this(string.Format("autogen-{0}", Guid.NewGuid()), settings, columns, records, postbacks, enableStatusColumn) { }

        ///// <summary>
        ///// Constructor to initialize with an HTML field ID
        ///// </summary>
        ///// <param name="id">HTML field ID for the Datatable</param>
        ///// <param name="settings">Datatable settings</param>
        ///// <param name="columns">Datatable column specifications</param>
        ///// <param name="records">Datatable records</param>
        ///// <param name="postbacks">[Optional] Postback data for server side processing</param>
        ///// <param name="enableStatusColumn">[Optional] flag indicating whether to enable status column. Defaults to false</param>
        //[Obsolete("Use Ctor(id, settings, records, postbacks, enableStatusColumn) instead")]
        //public Datatable(string id, DatatableSettings settings, IEnumerable<DatatableColumn> columns,
        //  DatatableRecords records, IEnumerable<PostbackItem> postbacks = null, bool enableStatusColumn = false)
        //{
        //  ID = id.Replace("-", "_");
        //  Settings = settings;

        //  // sanitize the datatable column widths
        //  IEnumerable<DatatableColumn> datatableColumns = columns as DatatableColumn[] ?? columns.ToArray();
        //  int nullWidthColumns = datatableColumns.Count(f => !f.Width.HasValue);
        //  int widthAssigned = datatableColumns.Select(f => f.Width != null ? f.Width.Value : 0).Sum();
        //  int widthLeft = 100 - widthAssigned;

        //  datatableColumns.Where(f => !f.Width.HasValue).ToList().ForEach(f => { f.Width = widthLeft / nullWidthColumns; });

        //  // setup the status column if the flag is set
        //  if (enableStatusColumn)
        //    datatableColumns = datatableColumns.Concat(new[] { new DatatableColumn("", visible: false, bSortable: false) });

        //  // if the aoColumns were not setup then do a default setup
        //  if (settings.aoColumns == null)
        //    settings.SetupAOColumns(datatableColumns);

        //  Columns = datatableColumns.ToArray();
        //  Records = records;
        //  Postbacks = postbacks != null ? postbacks.ToArray() : new PostbackItem[0];
        //  EnableStatusColumn = enableStatusColumn;
        //}

        /// <summary>
        /// Constructor. Note. The column specifications must be defined via the DatatableSettings constructor
        /// </summary>
        /// <param name="settings">Datatable settings</param>
        /// <param name="records">Datatable records</param>
        /// <param name="postbacks">[Optional] Postback data for server side processing</param>
        /// <param name="enableStatusColumn">[Optional] flag indicating whether to enable status column. Defaults to false</param>
        public Datatable(DatatableSettings settings, DatatableRecords records, IEnumerable <PostbackItem> postbacks = null, bool enableStatusColumn = false) :
            this(string.Format("autogen-{0}", Guid.NewGuid()), settings, records, postbacks, enableStatusColumn)
        {
        }