예제 #1
0
 internal static JsonTreeResponse PrepareJsonTreeResponse(JsonTreeResponse response, JQGrid grid, DataTable dt)
 {
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         response.rows[i] = new Hashtable();
         for (int j = 0; j < grid.Columns.Count; j++)
         {
             JQGridColumn jQGridColumn = grid.Columns[j];
             string value = "";
             if (!string.IsNullOrEmpty(jQGridColumn.DataField))
             {
                 Guard.IsNull(dt.Columns[jQGridColumn.DataField], "The column with DataField=" + jQGridColumn.DataField + " does not exist in the datasource.");
                 int ordinal = dt.Columns[jQGridColumn.DataField].Ordinal;
                 value = (string.IsNullOrEmpty(jQGridColumn.DataFormatString) ? dt.Rows[i].ItemArray[ordinal].ToString() : jQGridColumn.FormatDataValue(dt.Rows[i].ItemArray[ordinal], jQGridColumn.HtmlEncode));
             }
             response.rows[i].Add(jQGridColumn.DataField, value);
         }
         try
         {
             response.rows[i].Add("tree_level", dt.Rows[i]["tree_level"] as int?);
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_parent", Convert.ToString(dt.Rows[i]["tree_parent"]));
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_leaf", Convert.ToBoolean(dt.Rows[i]["tree_leaf"]));
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_expanded", Convert.ToBoolean(dt.Rows[i]["tree_expanded"]));
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_loaded", Convert.ToBoolean(dt.Rows[i]["tree_loaded"]));
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_icon", Convert.ToString(dt.Rows[i]["tree_icon"]));
         }
         catch
         {
         }
     }
     return response;
 }
예제 #2
0
 internal static string ConvertToTreeJson(JsonTreeResponse response, JQGrid grid, DataTable dt)
 {
     object obj = Util.PrepareJsonTreeResponse(response, grid, dt);
     return new JavaScriptSerializer().Serialize(obj);
 }
예제 #3
0
 private void PerformRequestData(IEnumerable retrievedData)
 {
     DataView defaultView = this.GetDataTableFromIEnumerable(retrievedData).DefaultView;
     int num = Convert.ToInt32(this.QueryString["page"]);
     int num2 = Convert.ToInt32(this.QueryString["rows"]);
     string sortExpression = this.QueryString["sidx"];
     string sortDirection = this.QueryString["sord"];
     string search = this.QueryString["_search"];
     if (this._totalRows > 0)
     {
         this._selectArguments.TotalRowCount = this._totalRows;
     }
     if (this._filteredGridState != null && this.ExportSettings.ExportDataRange != ExportDataRange.FilteredAndPaged)
     {
         num = 1;
     }
     this.PerformSearch(defaultView, search);
     int num3 = (this._selectArguments.TotalRowCount > -1) ? this._selectArguments.TotalRowCount : defaultView.Count;
     int totalPagesCount = (int)Math.Ceiling((double)((float)num3 / (float)num2));
     if (!this._dataSourceSorted)
     {
         this.PerformSort(defaultView, sortExpression, sortDirection);
     }
     else
     {
         new JQGridSortEventArgs(sortExpression, sortDirection);
         this.OnSorted(new EventArgs());
     }
     DataTable dataTable = defaultView.ToTable();
     DataTable dataTable2 = dataTable;
     if ((num - 1) * num2 >= num3 && num > 1)
     {
         num--;
     }
     int startIndex = (num - 1) * num2;
     int num4 = (num - 1) * num2 + num2;
     if (num4 > num3)
     {
         num4 = num3;
     }
     if (num4 <= dataTable.Rows.Count)
     {
         dataTable2 = this.GetPagedDataTable(startIndex, num4, dataTable);
     }
     JQGrid.JQGridDataRequestedEventHandler jQGridDataRequestedEventHandler = (JQGrid.JQGridDataRequestedEventHandler)base.Events[JQGrid.EventDataRequested];
     if (jQGridDataRequestedEventHandler != null)
     {
         this.OnDataRequested(new JQGridDataRequestedEventArgs(dataTable2));
     }
     if (this.IsGridExportActive())
     {
         DataTable dataSource = dataTable;
         if (this.ExportSettings.ExportDataRange == ExportDataRange.FilteredAndPaged)
         {
             dataSource = dataTable2;
         }
         if (this._filteredExcelExportActive)
         {
             this.DoExportToExcel(this._filteredExportFileName, this._filteredGridState, dataSource);
         }
         if (this._filteredCSVExportActive)
         {
             this.DoExportToCSV(this._filteredExportFileName, this._filteredGridState, dataSource);
         }
         if (this._filteredExportActive)
         {
             this.DoExportGridData(this._filteredGridState, dataSource);
         }
         return;
     }
     if (this.TreeGridSettings.Enabled)
     {
         JsonTreeResponse response = new JsonTreeResponse(num, totalPagesCount, num3, num2, dataTable2.Rows.Count, Util.GetFooterInfo(this));
         HttpContext.Current.Response.SendResponse(Util.ConvertToTreeJson(response, this, dataTable));
         return;
     }
     JsonResponse response2 = new JsonResponse(num, totalPagesCount, num3, num2, dataTable2.Rows.Count, Util.GetFooterInfo(this));
     HttpContext.Current.Response.SendResponse(Util.ConvertToJson(response2, this, dataTable2));
 }