示例#1
0
 internal static JsonResponse PrepareJsonResponse(JsonResponse response, JQGrid grid, DataTable dt)
 {
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string[] array = new string[grid.Columns.Count];
         for (int j = 0; j < grid.Columns.Count; j++)
         {
             JQGridColumn jQGridColumn = grid.Columns[j];
             string       text         = "";
             if (!string.IsNullOrEmpty(jQGridColumn.DataField))
             {
                 int ordinal = dt.Columns[jQGridColumn.DataField].Ordinal;
                 text = (string.IsNullOrEmpty(jQGridColumn.DataFormatString) ? dt.Rows[i].ItemArray[ordinal].ToString() : jQGridColumn.FormatDataValue(dt.Rows[i].ItemArray[ordinal], jQGridColumn.HtmlEncode));
             }
             array[j] = text;
         }
         string  id      = array[Util.GetPrimaryKeyIndex(grid)];
         JsonRow jsonRow = new JsonRow();
         jsonRow.id       = id;
         jsonRow.cell     = array;
         response.rows[i] = jsonRow;
     }
     return(response);
 }
示例#2
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))
             {
                 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", dt.Rows[i]["tree_leaf"] as bool?);
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_expanded", dt.Rows[i]["tree_expanded"] as bool?);
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_loaded", dt.Rows[i]["tree_loaded"] as bool?);
         }
         catch
         {
         }
         try
         {
             response.rows[i].Add("tree_icon", dt.Rows[i]["tree_icon"] as string);
         }
         catch
         {
         }
     }
     return(response);
 }
示例#3
0
 internal static JsonResponse PrepareJsonResponse(JsonResponse response, JQGrid grid, DataTable dt)
 {
     for (int i = 0; i < dt.Rows.Count; i++)
     {
         string[] strArray = new string[grid.Columns.Count];
         for (int j = 0; j < grid.Columns.Count; j++)
         {
             JQGridColumn column = grid.Columns[j];
             string       str    = "";
             if (!string.IsNullOrEmpty(column.DataField))
             {
                 int ordinal = dt.Columns[column.DataField].Ordinal;
                 str = string.IsNullOrEmpty(column.DataFormatString) ? dt.Rows[i].ItemArray[ordinal].ToString() : column.FormatDataValue(dt.Rows[i].ItemArray[ordinal], column.HtmlEncode);
             }
             strArray[j] = str;
         }
         string  str2 = strArray[GetPrimaryKeyIndex(grid)];
         JsonRow row  = new JsonRow();
         row.id           = str2;
         row.cell         = strArray;
         response.rows[i] = row;
     }
     return(response);
 }