Exemplo n.º 1
0
 private void OnTableRowCreated(Table.Row Row)
 {
     if (!this.Configuration.Editable && (Row.Data != null) && !string.IsNullOrEmpty(this.Configuration.EditLink))
     {
         Reflection.Accessor Accessor = new Reflection.Accessor();
         Accessor.Item       = Row.Data;
         Accessor.MemberName = "ID";
         Row.OnClick         = "document.location.href='" + this.Configuration.EditLink + "/" + Convert.ToString(Accessor.Value) + "'";
     }
 }
Exemplo n.º 2
0
        public override void DataBind()
        {
            IEnumerable DataSourceToBind = this.DataSource;

            this.OnBeforeDataBind(ref DataSourceToBind);

            this.Table.Rows.Clear();
            this.Table.Editable = this.Configuration.Editable;
            if (this.DataSource != null)
            {
                long TotalCount = 0;
                this.Table.Accessor.Item       = DataSourceToBind;
                this.Table.Accessor.MemberName = "Count";
                try {
                    TotalCount = Convert.ToInt64(this.Table.Accessor.Value);
                } catch {
                    this.Table.Accessor.MemberName = "Length";
                    TotalCount = Convert.ToInt64(this.Table.Accessor.Value);
                }
                this.Table.Rows.Clear();
                int n = 0;
                if (this.Table.ShowColumnHeader)
                {
                    if (this.Table.Rows.Count == 0)
                    {
                        this.Table.Rows.Add();
                    }
                    for (n = 0; n <= this.Table.Columns.Count - 1; n++)
                    {
                        this.Table.Rows[0][n].Text = this.Table.Columns[n].MemberName;
                    }
                }
                if (TotalCount > 0)
                {
                    n = 1;
                    foreach (object Item in DataSourceToBind)
                    {
                        this.Table.Rows.Add(Item).Bind();
                        this.OnRowBinded(this.Table.Rows.LastRow);
                        this.Table.Rows.LastRow.StyleClass += n % 2 > 0 ? " Odd" : " Even";
                        n += 1;
                    }
                }
                if (this.Configuration.AllowNewRow)
                {
                    this.Table.Rows.Add(this.CreateBlankItem()).Bind();
                    this.Table.Rows.LastRow.IsNew = true;

                    Reflection.Accessor Accessor = new Reflection.Accessor();
                    Accessor.Item       = this.DataSource;
                    Accessor.MemberName = "Count";
                    long x = Convert.ToInt64(Accessor.Value);
                    this.OnRowBinded(this.Table.Rows.LastRow);
                    this.Table.Rows.LastRow.StyleClass += n % 2 > 0 ? " Odd" : " Even";
                }
                else if (TotalCount == 0)
                {
                    this.Table.Visible  = false;
                    this.Footer.Visible = false;
                }
            }
            DataSourceToBind = null;
            this.OnAfterDataBind();
        }