Example #1
0
        private static void ValidateJqGridConstraints(JqGridOptions options)
        {
            if ((options.InlineNavigator != null) && (options.Navigator == null))
            {
                throw new InvalidOperationException("In order to set up Inline Navigator you must set up Navigator as well.");
            }

            if ((options.SubgridModel != null) && (options.SubgridOptions != null))
            {
                throw new InvalidOperationException("Subgrid model and subgrid options can't be used at the same time.");
            }

            if ((options.SubgridOptions != null) && !String.IsNullOrWhiteSpace(options.SubGridRowExpanded))
            {
                throw new InvalidOperationException("Subgrid options and subGridRowExpanded can't be used at the same time.");
            }

            if (options.TreeGridEnabled && options.GroupingEnabled)
            {
                throw new InvalidOperationException("TreeGrid and data grouping can not be enabled at the same time.");
            }

            if ((options.DynamicScrollingMode != JqGridDynamicScrollingModes.Disabled) && options.GroupingEnabled)
            {
                throw new InvalidOperationException("Dynamic scrolling and data grouping can not be enabled at the same time.");
            }
        }
Example #2
0
 private static void ValidateJqGridConstraints(JqGridOptions options)
 {
     if ((options.DynamicScrollingMode != JqGridDynamicScrollingModes.Disabled) && options.GroupingEnabled)
     {
         throw new InvalidOperationException("Dynamic scrolling and data grouping can not be enabled at the same time.");
     }
 }
Example #3
0
        public ActionResult Index()
        {
            var data = new List<DataItem>
                {
                    new DataItem(){Name="Roxy", InvDate = new DateTime(1979,2,26)},
                    new DataItem{Name="Dru", InvDate = new DateTime(2010,10,1)}
                };

            var rtp = ReportDefinition.New<DataItem>(cfg=>
            {
                cfg.Column(d=>d.Name);
                cfg.Column(d=>d.InvDate, e=>e.SetDisplayName("Invoice Date"));
            });

            var o = new JqGridOptions();
            o.Data = data;

            foreach (var column in rtp.Columns)
            {
                o.Columns.Add(new JqColumnModel()
                    {
                        Name = column.Name,
                        DisplayName = column.DisplayName,
                        Index = column.Name,
                        SortType = column.Type.GetJqType(),
                        Width = 100,
                        Funk = column.Funk
                    });
            }

            return View(o);
        }
        public void AppendOptions_OnSelectRowIsNull_ScriptDoesNotContainOnSelectRowOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID);

            javaScriptBuilder = javaScriptBuilder.AppendOptions(options, jqGridJsonServiceStub, false);

            Assert.DoesNotContain(ON_SELECT_ROW_OPTION, javaScriptBuilder.ToString());
        }
Example #5
0
 /// <summary>
 /// Returns the HTML that is used to render the table placeholder for the grid with pager placeholder below it and filter grid (if enabled) placeholder above it.
 /// </summary>
 /// <returns>The HTML that represents the table placeholder for jqGrid with pager placeholder below i</returns>
 public static IHtmlContent JqGridHtml(this IHtmlHelper htmlHelper, JqGridOptions options)
 {
     if (options.Pager)
     {
         return(new HtmlString(htmlHelper.JqGridTableHtml(options).ToString() + htmlHelper.JqGridPagerHtml(options).ToString()));
     }
     else
     {
         return(htmlHelper.JqGridTableHtml(options));
     }
 }
        public void AppendOptions_LoadCompleteIsNull_ScriptDoesNotContainLoadCompleteOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID);

            javaScriptBuilder = javaScriptBuilder.AppendOptions(options, jqGridJsonServiceStub, false);

            Assert.DoesNotContain(LOAD_COMPLETE_OPTION, javaScriptBuilder.ToString());
        }
Example #7
0
        public JqGridBuilder(string id)
        {
            Id = id;

            _jqGridOptions = new JqGridOptions()
            {
                viewrecords = true,
                pager       = Id + "_Pager",
                colModel    = new List <JqGridColumn>(),
            };

            _complementoJqGrid = string.Empty;
        }
Example #8
0
        public void AppendColumnsModels_XmlMappingIsNull_ScriptDoesNotContainXmlMapOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID);

            options.AddColumn(SOME_COLUMN_NAME, new JqGridColumnModel(SOME_COLUMN_NAME));

            javaScriptBuilder = javaScriptBuilder.AppendColumnsModels(options, jqGridJsonServiceStub, false);

            Assert.DoesNotContain(XML_MAP_OPTION, javaScriptBuilder.ToString());
        }
        public void AppendOptions_LoadCompleteIsNotNull_ScriptContainsLoadCompleteOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                LoadComplete = SOME_LOAD_COMPLETE_FUNCTION
            };

            javaScriptBuilder = javaScriptBuilder.AppendOptions(options, jqGridJsonServiceStub, false);

            Assert.Contains($"{LOAD_COMPLETE_OPTION}{SOME_LOAD_COMPLETE_FUNCTION},", javaScriptBuilder.ToString());
        }
        public void AppendOptions_OnSelectRowIsNotNull_ScriptContainsOnSelectRowOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                OnSelectRow = SOME_ON_SELECT_ROW_FUNCTION
            };

            javaScriptBuilder = javaScriptBuilder.AppendOptions(options, jqGridJsonServiceStub, false);

            Assert.Contains($"{ON_SELECT_ROW_OPTION}{SOME_ON_SELECT_ROW_FUNCTION},", javaScriptBuilder.ToString());
        }
Example #11
0
        /// <summary>
        /// Return the JavaScript that is used to initialize jqGrid with given options.
        /// </summary>
        /// <returns>The JavaScript that initializes jqGrid with give options</returns>
        /// <exception cref="System.InvalidOperationException">
        /// <list type="bullet">
        /// <item><description>TreeGrid and data grouping are both enabled.</description></item>
        /// <item><description>Rows numbers and data grouping are both enabled.</description></item>
        /// <item><description>Dynamic scrolling and data grouping are both enabled.</description></item>
        /// <item><description>TreeGrid and GridView are both enabled.</description></item>
        /// <item><description>SubGrid and GridView are both enabled.</description></item>
        /// <item><description>AfterInsertRow event and GridView are both enabled.</description></item>
        /// </list>
        /// </exception>
        public static IHtmlContent JqGridJavaScript(this IHtmlHelper htmlHelper, JqGridOptions options)
        {
            ValidateJqGridConstraints(options);

            IUrlHelperFactory urlHelperFactory = (IUrlHelperFactory)htmlHelper.ViewContext.HttpContext.RequestServices.GetService(typeof(IUrlHelperFactory));

            options.ApplyModelMetadata(htmlHelper.MetadataProvider, urlHelperFactory.GetUrlHelper(htmlHelper.ViewContext));

            StringBuilder javaScriptBuilder = new StringBuilder();

            javaScriptBuilder.AppendFormat("$('#{0}')", options.Id)
            .AppendJqGridScript(options, false);

            return(new HtmlString(javaScriptBuilder.ToString()));
        }
Example #12
0
        /// <summary>
        /// Populates the JqGridOptions from the columns specified by the controller
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public JqGridOptions InitializeOptions(JqGridOptions options)
        {
            foreach (var column in Columns)
            {
                options.ColumnNames.Add(column.DisplayName);

                options.ColumnModels.Add(new ColumnModel
                {
                    Index    = column.DisplayName,
                    Name     = column.Name,
                    Sortable = column.Sortable
                });
            }
            return(options);
        }
        internal static void ApplyModelMetadata(this JqGridOptions options, IModelMetadataProvider metadataProvider)
        {
            Type jqGridOptionsType = options.GetType();

            if (jqGridOptionsType.IsConstructedGenericType && jqGridOptionsType.GetGenericTypeDefinition() == typeof(JqGridOptions <>))
            {
                foreach (ModelMetadata columnMetadata in metadataProvider.GetMetadataForProperties(jqGridOptionsType.GenericTypeArguments[0]))
                {
                    if (IsValidForColumn(columnMetadata))
                    {
                        options.AddColumn(columnMetadata.GetDisplayName(), CreateJqGridColumnModel(columnMetadata));
                    }
                }
            }
        }
        public void AppendSubgrid_SubgridEnabledAndSubgridOptionsIsNullAndSubgridUrlIsNullAndSubgridModelIsNullAndSubGridRowExpandedIsNull_ScriptDoesNotContainSubgridEnabledOption()
        {
            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                SubgridEnabled     = true,
                SubgridOptions     = null,
                SubgridUrl         = null,
                SubgridModel       = null,
                SubGridRowExpanded = null
            };

            javaScriptBuilder = javaScriptBuilder.AppendSubgrid(options);

            Assert.DoesNotContain(SUBGRID_ENABLED_OPTION, javaScriptBuilder.ToString());
        }
        public void AppendSubgrid_SubgridEnabledAndSubgridOptionsIsNullAndSubgridUrlIsNullAndSubgridModelIsNullAndSubGridRowExpandedIsNotNull_ScriptContainsSubgridRowExpandedOption()
        {
            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                SubgridEnabled     = true,
                SubgridOptions     = null,
                SubgridUrl         = null,
                SubgridModel       = null,
                SubGridRowExpanded = SOME_SUBGRID_ROW_EXPANDED_FUNCTION
            };

            javaScriptBuilder = javaScriptBuilder.AppendSubgrid(options);

            Assert.Contains(SUBGRID_ROW_EXPANDED_OPTION, javaScriptBuilder.ToString());
        }
Example #16
0
        public void AppendOptions_KeyIsTrue_ScriptContainsKeyOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID);

            options.AddColumn(SOME_COLUMN_NAME, new JqGridColumnModel(SOME_COLUMN_NAME)
            {
                Key = true
            });

            javaScriptBuilder = javaScriptBuilder.AppendColumnsModels(options, jqGridJsonServiceStub, false);

            Assert.Contains($"{KEY_OPTION}true", javaScriptBuilder.ToString());
        }
Example #17
0
        public void AppendOptions_JsonMappingIsNotNull_ScriptContainsJsonMapOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID);

            options.AddColumn(SOME_COLUMN_NAME, new JqGridColumnModel(SOME_COLUMN_NAME)
            {
                JsonMapping = SOME_JSON_MAP
            });

            javaScriptBuilder = javaScriptBuilder.AppendColumnsModels(options, jqGridJsonServiceStub, false);

            Assert.Contains($"{JSON_MAP_OPTION}'{SOME_JSON_MAP}'", javaScriptBuilder.ToString());
        }
Example #18
0
        public void ApplyModelMetadata_DefaultColumn_KeyIsFalse()
        {
            Mock <IModelMetadataProvider> metadataProviderStub = new Mock <IModelMetadataProvider>();

            metadataProviderStub.Setup(m => m.GetMetadataForProperties(SOME_GRID_MODEL_TYPE)).Returns(new[]
            {
                (ModelMetadata) new JqGridColumnModelMetadata(SOME_GRID_COLUMN_TYPE, nameof(SomeGridModel.DefaultColumn), SOME_GRID_MODEL_TYPE)
            });

            Mock <IUrlHelper>             urlHelperStub = new Mock <IUrlHelper>();
            JqGridOptions <SomeGridModel> options       = new JqGridOptions <SomeGridModel>(SOME_GRID_ID);


            options.ApplyModelMetadata(metadataProviderStub.Object, urlHelperStub.Object);

            Assert.False(options.ColumnsModels.Single(c => c.Name == nameof(SomeGridModel.DefaultColumn)).Key);
        }
Example #19
0
        public void ApplyModelMetadata_MappedColumn_JsonMappingIsSet()
        {
            Mock <IModelMetadataProvider> metadataProviderStub = new Mock <IModelMetadataProvider>();

            metadataProviderStub.Setup(m => m.GetMetadataForProperties(SOME_GRID_MODEL_TYPE)).Returns(new[]
            {
                (ModelMetadata) new JqGridColumnModelMetadata(SOME_GRID_COLUMN_TYPE, nameof(SomeGridModel.MappedColumn), SOME_GRID_MODEL_TYPE)
            });

            Mock <IUrlHelper>             urlHelperStub = new Mock <IUrlHelper>();
            JqGridOptions <SomeGridModel> options       = new JqGridOptions <SomeGridModel>(SOME_GRID_ID);


            options.ApplyModelMetadata(metadataProviderStub.Object, urlHelperStub.Object);

            Assert.Equal(SOME_JSON_MAP, options.ColumnsModels.Single(c => c.Name == nameof(SomeGridModel.MappedColumn)).JsonMapping);
        }
Example #20
0
        public void AppendSubgrid_SubgridDisabledAndSubgridOptionsIsNullAndSubgridUrlIsNullAndSubgridModelIsNullAndSubGridRowExpandedIsNull_ScriptDoesNotContainSubgridModelOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                SubgridEnabled     = false,
                SubgridOptions     = null,
                SubgridUrl         = null,
                SubgridModel       = null,
                SubGridRowExpanded = null
            };

            javaScriptBuilder = javaScriptBuilder.AppendSubgrid(options, jqGridJsonServiceStub);

            Assert.DoesNotContain(SUBGRID_MODEL_OPTION, javaScriptBuilder.ToString());
        }
Example #21
0
        /// <summary>
        /// Return the JavaScript that is used to initialize jqGrid with given options.
        /// </summary>
        /// <returns>The JavaScript that initializes jqGrid with give options</returns>
        /// <exception cref="System.InvalidOperationException">
        /// <list type="bullet">
        /// <item><description>TreeGrid and data grouping are both enabled.</description></item>
        /// <item><description>Rows numbers and data grouping are both enabled.</description></item>
        /// <item><description>Dynamic scrolling and data grouping are both enabled.</description></item>
        /// <item><description>TreeGrid and GridView are both enabled.</description></item>
        /// <item><description>SubGrid and GridView are both enabled.</description></item>
        /// <item><description>AfterInsertRow event and GridView are both enabled.</description></item>
        /// </list>
        /// </exception>
        public static IHtmlContent JqGridJavaScript(this IHtmlHelper htmlHelper, JqGridOptions options)
        {
            ValidateJqGridConstraints(options);

            options.ApplyModelMetadata(htmlHelper.MetadataProvider);

            StringBuilder javaScriptBuilder = new StringBuilder();

            javaScriptBuilder.AppendFormat("$({0}).jqGrid({{", GetJqGridGridSelector(options, false)).AppendLine()
            .AppendJavaScriptObjectStringArrayField(JqGridOptionsNames.COLUMNS_NAMES_FIELD, options.ColumnsNames)
            .AppendColumnsModels(options)
            .AppendOptions(options)
            .Append("})");

            javaScriptBuilder.AppendLine(";");

            return(new HtmlString(javaScriptBuilder.ToString()));
        }
Example #22
0
        public void AppendSubgrid_SubgridEnabledAndSubgridOptionsIsNullAndSubgridUrlIsNotNullAndSubgridModelIsNotNullAndSubGridRowExpandedIsNull_ScriptContainsSubgridEnabledOption()
        {
            IJqGridJsonService jqGridJsonServiceStub = new Mock <IJqGridJsonService>().Object;

            StringBuilder javaScriptBuilder = new StringBuilder();
            JqGridOptions options           = new JqGridOptions(SOME_GRID_ID)
            {
                SubgridEnabled     = true,
                SubgridOptions     = null,
                SubgridUrl         = SOME_SUBGRID_URL,
                SubgridModel       = new JqGridSubgridModel(),
                SubGridRowExpanded = null
            };

            javaScriptBuilder = javaScriptBuilder.AppendSubgrid(options, jqGridJsonServiceStub);

            Assert.Contains(SUBGRID_ENABLED_OPTION, javaScriptBuilder.ToString());
        }
        internal static void ApplyModelMetadata(this JqGridOptions options, IModelMetadataProvider metadataProvider, IUrlHelper urlHelper)
        {
            IJqGridStronglyTypedOptions jqGridStronglyTypedOptions = options as IJqGridStronglyTypedOptions;

            if (jqGridStronglyTypedOptions != null)
            {
                foreach (ModelMetadata columnMetadata in metadataProvider.GetMetadataForProperties(jqGridStronglyTypedOptions.ModelType))
                {
                    if (IsValidForColumn(columnMetadata))
                    {
                        options.AddColumn(columnMetadata.GetDisplayName(), CreateJqGridColumnModel(columnMetadata, urlHelper));
                    }
                }

                if (jqGridStronglyTypedOptions.ActionsColumn != null)
                {
                    if (jqGridStronglyTypedOptions.ActionsColumn.Position >= options.ColumnsModels.Count)
                    {
                        options.AddColumn(_actionsColumnDisplayName, CreateActionsColumnModel(jqGridStronglyTypedOptions.ActionsColumn));
                    }
                    else
                    {
                        options.InsertColumn(jqGridStronglyTypedOptions.ActionsColumn.Position, _actionsColumnDisplayName, CreateActionsColumnModel(jqGridStronglyTypedOptions.ActionsColumn));
                    }
                }
            }

            if (options.SubgridEnabled)
            {
                if (options.SubgridOptions != null)
                {
                    options.SubgridOptions.ApplyModelMetadata(metadataProvider, urlHelper);
                }
                else if (options.SubgridModel != null)
                {
                    options.SubgridModel.ApplyModelMetadata(metadataProvider);
                }
            }
        }
Example #24
0
        private static StringBuilder AppendCellEditing(this StringBuilder javaScriptBuilder, JqGridOptions options)
        {
            if (options.CellEditingEnabled)
            {
                javaScriptBuilder.AppendJavaScriptObjectBooleanField(JqGridOptionsNames.CELL_EDITING, true);

                if (options.CellEditingSubmitMode == JqGridCellEditingSubmitModes.ClientArray)
                {
                    javaScriptBuilder.AppendJavaScriptObjectStringField(JqGridOptionsNames.CELL_EDITING_SUBMIT_MODE, "clientArray");
                }
                else
                {
                    javaScriptBuilder.AppendJavaScriptObjectStringField(JqGridOptionsNames.CELL_EDITITNG_URL, options.CellEditingUrl);
                }
            }

            return(javaScriptBuilder);
        }
Example #25
0
        private static StringBuilder AppendSubgridAsGridRowExpanded(this StringBuilder javaScriptBuilder, JqGridOptions options)
        {
            javaScriptBuilder.AppendFormat("{0}: function (subgridId, rowId) {{", JqGridOptionsNames.SUBGRID_ROW_EXPANDED)
            .Append("var $subgridContainer = jQuery('#' + subgridId);")
            .AppendFormat("var {0} = jQuery('<table></table').attr('id', subgridId + '_t');", SUBGRID_VARIABLE)
            .AppendFormat("$subgridContainer.append({0});", SUBGRID_VARIABLE);

            if (options.SubgridOptions.Pager)
            {
                javaScriptBuilder.AppendFormat("var $subgridPager = jQuery('<div></div>').attr('id', {0});", SUBGRID_PAGER_ID)
                .Append("$subgridContainer.append($subgridPager);");
            }

            javaScriptBuilder.Append(SUBGRID_VARIABLE)
            .AppendJqGridScript(options.SubgridOptions, true)
            .Append("},");

            return(javaScriptBuilder);
        }
Example #26
0
        private static StringBuilder AppendCoreSubgridOptions(this StringBuilder javaScriptBuilder, JqGridOptions options)
        {
            javaScriptBuilder.AppendJavaScriptObjectBooleanField(JqGridOptionsNames.SUBGRID_ENABLED, true)
            .AppendJavaScriptObjectIntegerField(JqGridOptionsNames.SUBGRID_WIDTH, options.SubgridColumnWidth, JqGridOptionsDefaults.SubgridColumnWidth)
            .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.SUBGRID_BEFORE_EXPAND, options.SubGridBeforeExpand)
            .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.SUBGRID_ROW_COLAPSED, options.SubGridRowColapsed);

            return(javaScriptBuilder);
        }
Example #27
0
        internal static StringBuilder AppendSubgrid(this StringBuilder javaScriptBuilder, JqGridOptions options)
        {
            if (options.SubgridEnabled && (options.SubgridOptions != null))
            {
                javaScriptBuilder.AppendCoreSubgridOptions(options)
                .AppendSubgridAsGridRowExpanded(options);
            }
            else if (options.SubgridEnabled && !String.IsNullOrWhiteSpace(options.SubgridUrl) && (options.SubgridModel != null))
            {
                javaScriptBuilder.AppendCoreSubgridOptions(options)
                .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.SUBGRID_ROW_EXPANDED, options.SubGridRowExpanded)
                .AppendJavaScriptObjectStringField(JqGridOptionsNames.SUBGRID_ULR, options.SubgridUrl)
                .AppendJavaScriptArrayFieldOpening(JqGridOptionsNames.SUBGRID_MODEL)
                .AppendJavaScriptObjectOpening()
                .AppendJavaScriptObjectStringArrayField(JqGridOptionsNames.SubgridModel.NAMES, options.SubgridModel.ColumnsModels.Select(c => c.Name))
                .AppendJavaScriptObjectIntegerArrayField(JqGridOptionsNames.SubgridModel.WIDTHS, options.SubgridModel.ColumnsModels.Select(c => c.Width))
                .AppendJavaScriptObjectEnumArrayField(JqGridOptionsNames.SubgridModel.ALIGNMENTS, options.SubgridModel.ColumnsModels.Select(c => c.Alignment))
                .AppendJavaScriptObjectStringArrayField(JqGridOptionsNames.SubgridModel.MAPPINGS, options.SubgridModel.ColumnsModels.Select(c => c.Mapping))
                .AppendJavaScriptObjectStringArrayField(JqGridOptionsNames.SubgridModel.PARAMETERS, options.SubgridModel.Parameters)
                .AppendJavaScriptObjectFieldClosing()
                .AppendJavaScriptArrayFieldClosing();
            }
            else if (options.SubgridEnabled && !String.IsNullOrWhiteSpace(options.SubGridRowExpanded))
            {
                javaScriptBuilder.AppendCoreSubgridOptions(options)
                .AppendJavaScriptObjectFunctionField(JqGridOptionsNames.SUBGRID_ROW_EXPANDED, options.SubGridRowExpanded);
            }

            return(javaScriptBuilder);
        }
Example #28
0
        private static StringBuilder AppendDataSource(this StringBuilder javaScriptBuilder, JqGridOptions options, bool asSubgrid)
        {
            if (options.DataType.IsDataStringDataType())
            {
                javaScriptBuilder.AppendJavaScriptObjectStringField(JqGridOptionsNames.DATA_STRING, options.DataString);
            }
            else
            {
                if (asSubgrid && !String.IsNullOrWhiteSpace(options.Url))
                {
                    if (options.Url.Contains("?"))
                    {
                        javaScriptBuilder.AppendFormat("{0}:'{1}&rowId=' + encodeURIComponent(rowId),", JqGridOptionsNames.URL, options.Url);
                    }
                    else
                    {
                        javaScriptBuilder.AppendFormat("{0}:'{1}?rowId=' + encodeURIComponent(rowId),", JqGridOptionsNames.URL, options.Url);
                    }
                }
                else
                {
                    javaScriptBuilder.AppendJavaScriptObjectStringField(JqGridOptionsNames.URL, options.Url);
                }

                javaScriptBuilder.AppendJavaScriptObjectEnumField(JqGridOptionsNames.METHOD_TYPE, options.MethodType, JqGridOptionsDefaults.MethodType);
            }

            return(javaScriptBuilder);
        }
Example #29
0
 internal static string GetJqGridPager(JqGridOptions options, bool asSubgrid)
 {
     return(asSubgrid ? "$subgridPager" : String.Format("'#{0}'", options.GetJqGridPagerId()));
 }
Example #30
0
        private static StringBuilder AppendPostData(this StringBuilder javaScriptBuilder, JqGridOptions options, IJqGridJsonService jqGridJsonService)
        {
            if (!String.IsNullOrWhiteSpace(options.PostDataScript))
            {
                javaScriptBuilder.AppendJavaScriptObjectFunctionField(JqGridOptionsNames.POST_DATA, options.PostDataScript);
            }
            else if (options.PostData != null)
            {
                javaScriptBuilder.AppendJavaScriptObjectJqGridObjectField(JqGridOptionsNames.POST_DATA, options.PostData, jqGridJsonService);
            }

            return(javaScriptBuilder);
        }
Example #31
0
        private static StringBuilder AppendPager(this StringBuilder javaScriptBuilder, JqGridOptions options, bool asSubgrid)
        {
            if (options.Pager)
            {
                javaScriptBuilder.AppendJavaScriptObjectFunctionField(JqGridOptionsNames.PAGER, GetJqGridPager(options, asSubgrid))
                .AppendJavaScriptObjectIntegerArrayField(JqGridOptionsNames.ROWS_LIST, options.RowsList)
                .AppendJavaScriptObjectIntegerField(JqGridOptionsNames.ROWS_NUMBER, options.RowsNumber, JqGridOptionsDefaults.RowsNumber)
                .AppendJavaScriptObjectBooleanField(JqGridOptionsNames.VIEW_RECORDS, options.ViewRecords, JqGridOptionsDefaults.ViewRecords);
            }

            return(javaScriptBuilder);
        }