Ejemplo n.º 1
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderContainerAsync(GridRecordData model)
        {
            ScriptBuilder sb = new ScriptBuilder();

            GridDictionaryInfo.ReadGridDictionaryInfo dictInfo = await GridDictionaryInfo.LoadGridColumnDefinitionsAsync(model.GridDef);

            // render record
            string tr = await GridDisplayComponent.RenderRecordHTMLAsync(HtmlHelper, model.GridDef, dictInfo, model.FieldPrefix, model.Data, 0, 0, false);

            GridRecordResult result = new GridRecordResult {
                TR         = tr,
                StaticData = model.Data,
            };

            sb.Append(Utility.JsonSerialize(result));

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderContainerAsync(GridPartialData model)
        {
            ScriptBuilder sb = new ScriptBuilder();

            GridDictionaryInfo.ReadGridDictionaryInfo dictInfo = await GridDictionaryInfo.LoadGridColumnDefinitionsAsync(model.GridDef);

            // render all records
            string data = await GridDisplayComponent.RenderTableHTML(HtmlHelper, model.GridDef, model.Data, model.StaticData, dictInfo, model.FieldPrefix, true, model.Skip, model.Take);

            data += Manager.ScriptManager.RenderEndofPageScripts();// portions generated by components

            int pages    = 0;
            int page     = 0;
            int pageSize = model.Take;

            if (model.Data.Total > 0)
            {
                if (model.Take == 0)
                {
                    pages    = 1;
                    pageSize = 0;
                }
                else
                {
                    pages = Math.Max(1, model.Data.Total / model.Take + (model.Data.Total % model.Take == 0 ? 0 : 1));
                    page  = Math.Max(model.Skip / model.Take, 0);
                }
            }

            GridPartialResult result = new GridPartialResult {
                Records  = model.Data.Total,
                TBody    = data,
                Pages    = pages,
                Page     = page,
                PageSize = pageSize,
            };

            sb.Append(Utility.JsonSerialize(result));

            return(sb.ToString());
        }