Exemple #1
0
        private static void WritePagingProperties(IJqGridJsonWriter writer, JqGridJsonReader jsonReader, JqGridResponse response)
        {
            writer.WriteProperty(jsonReader.PageIndex, response.PageIndex + 1);

            writer.WriteProperty(jsonReader.TotalRecordsCount, response.TotalRecordsCount);

            writer.WriteProperty(jsonReader.TotalPagesCount, response.TotalPagesCount);
        }
Exemple #2
0
        private static void WriteJqGridSearchingFilter(IJqGridJsonWriter writer, JqGridSearchingFilter jqGridSearchingFilter)
        {
            writer.WriteStartObject();

            writer.WriteProperty(SEARCHING_NAME_FIELD_NAME, jqGridSearchingFilter.SearchingName);

            writer.WriteProperty(SEARCHING_OPERATOR_FIELD_NAME, jqGridSearchingFilter.SearchingOperator.ToString().ToLowerInvariant());

            writer.WriteProperty(SEARCHING_VALUE_FIELD_NAME, jqGridSearchingFilter.SearchingValue);

            writer.WriteEndObject();
        }
Exemple #3
0
        /// <summary>
        /// Writes the JSON representation of the <see cref="JqGridSearchingFilters"/>.
        /// </summary>
        /// <param name="writer">The <see cref="IJqGridJsonWriter"/>.</param>
        /// <param name="jqGridSearchingFilters">The <see cref="JqGridSearchingFilters"/>.</param>
        public static void WriteJqGridSearchingFilters(IJqGridJsonWriter writer, JqGridSearchingFilters jqGridSearchingFilters)
        {
            writer.WriteStartObject();

            writer.WriteProperty(GROUPING_OPERATOR_FIELD_NAME, jqGridSearchingFilters.GroupingOperator.ToString().ToUpperInvariant());

            if ((jqGridSearchingFilters.Filters != null) && (jqGridSearchingFilters.Filters.Count > 0))
            {
                writer.WriteStartArray(FILTERS_FIELD_NAME);
                foreach (JqGridSearchingFilter jqGridRequestSearchingFilter in jqGridSearchingFilters.Filters)
                {
                    WriteJqGridSearchingFilter(writer, jqGridRequestSearchingFilter);
                }
                writer.WriteEndArray();
            }

            if ((jqGridSearchingFilters.Groups != null) && (jqGridSearchingFilters.Groups.Count > 0))
            {
                writer.WriteStartArray(GROUP_FIELD_NAME);
                foreach (JqGridSearchingFilters innerSearchingFilters in jqGridSearchingFilters.Groups)
                {
                    WriteJqGridSearchingFilters(writer, innerSearchingFilters);
                }
                writer.WriteEndArray();
            }

            writer.WriteEndObject();
        }
Exemple #4
0
        private static void WriteJqGridRecords(IJqGridJsonWriter writer, bool isSubgridResponse, JqGridJsonReader jsonReader, IList <JqGridRecord> records)
        {
            int  recordIdIndex       = 0;
            bool isRecordIndexInt    = Int32.TryParse(jsonReader.RecordId, out recordIdIndex);
            bool isRecordValuesEmpty = String.IsNullOrWhiteSpace(jsonReader.RecordValues);
            bool repeatItems         = isSubgridResponse ? jsonReader.SubgridReader.RepeatItems : jsonReader.RepeatItems;

            if (!isSubgridResponse)
            {
                if (repeatItems && isRecordValuesEmpty && !isRecordIndexInt)
                {
                    throw new InvalidOperationException("JqGridJsonReader.RecordId must be a number when JqGridJsonReader.RepeatItems is set to true and JqGridJsonReader.RecordValues is set to empty string.");
                }

                if (repeatItems && !isRecordValuesEmpty && isRecordIndexInt)
                {
                    throw new InvalidOperationException("JqGridJsonReader.RecordValues can't be an empty string when JqGridJsonReader.RepeatItems is set to true and JqGridJsonReader.RecordId is a number.");
                }
            }

            Func <JqGridJsonReader, JqGridRecord, bool, int, bool, object> serializeRecordFunction = ChooseSerializeFunction(repeatItems, isRecordValuesEmpty);
            IList <object> serializedRecords = new List <object>(records.Select(record => serializeRecordFunction(jsonReader, record, isRecordIndexInt, recordIdIndex, isSubgridResponse)));

            writer.WriteProperty(isSubgridResponse ? jsonReader.SubgridReader.Records : jsonReader.Records, serializedRecords);
        }
Exemple #5
0
 private static void WrtieUserData(IJqGridJsonWriter writer, JqGridJsonReader jsonReader, JqGridResponse response)
 {
     if (response.UserData != null)
     {
         writer.WriteProperty(jsonReader.UserData, response.UserData);
     }
 }