예제 #1
0
        public DataTable Select(ISelectQuery aQuery, OnRowSelect onExecute)
        {
            if (aQuery == null)
            {
                aQuery = QueryFactory.CreateSelectQuery();
            }

            DataRow   dr     = null;
            RowBinder binder = new RowBinder();
            int       i      = 0;

            binder.OnBind = delegate(DataRow aRow)
            {
                dr = aRow;
                if (onExecute != null)
                {
                    onExecute(dr, i);
                    i++;
                }
            };
            Connetion.execute(aQuery, binder);
            if (dr == null)
            {
                return(null);
            }

            return(dr.Table);
        }
예제 #2
0
        /// <summary>
        /// 数据绑定方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="data"></param>
        public void Execute <T>(List <T> data,
                                Action <RowBinder <T> > bind = null, Action <FooterBinder> footerBind = null)
        {
            _Grid.RowDataBound += (s, e) =>
            {
                if (e.Row.RowType != DataControlRowType.DataRow)
                {
                    return;
                }
                RowBinder <T> binder = new RowBinder <T>(e.Row, (T)e.Row.DataItem);
                if (bind != null)
                {
                    bind(binder);
                }
            };

            _Grid.DataSource = data;
            _Grid.DataBind();

            // 页脚
            if (footerBind != null && _Grid.FooterRow != null)
            {
                footerBind(new FooterBinder(_Grid.FooterRow));
            }

            // 注入 js 对象
            if (_Mode == SelectionMode.Multiple)
            {
                string arrDef = string.Empty;
                for (int i = 0; i < data.Count; i++)
                {
                    arrDef += arrDef.Length > 0 ? ",false" : "false";
                }
                ScriptManager.RegisterClientScriptBlock(this, GetType(), ClientID, string.Format(
                                                            "ISEx.resolve('{0}',{{selection:[{1}],hasChecked:function(){{var r=false;var x=this.selection;for(i=0;i<x.length;i++)if(x[i])r=true;return r;}}}});", ClientID, arrDef), true);
            }
        }
 public IReadOnlyList <T> GetResult <T>(string queryId)
 {
     return(RowBinder.BindResults <T>(GetResult(queryId)));
 }