@@ -50,7 +50,7 @@ public string ColumnDefsString
5050 {
5151 get
5252 {
53- return ConvertColumnDefsToJson ( Columns ) ;
53+ return ConvertColumnDefsToJson ( Columns . ToArray ( ) ) ;
5454 }
5555 }
5656 public bool ColumnFilter { get ; set ; }
@@ -227,13 +227,15 @@ private static string ConvertDictionaryToJsonBody(IDictionary<string, object> di
227227 return json . Substring ( 1 , json . Length - 2 ) ;
228228 }
229229
230- private static string ConvertColumnDefsToJson ( IEnumerable < ColDef > columns )
230+ private static string ConvertColumnDefsToJson ( ColDef [ ] columns )
231231 {
232232 var nonSortableColumns = columns . Select ( ( x , idx ) => x . Sortable ? - 1 : idx ) . Where ( x => x > - 1 ) . ToArray ( ) ;
233233 var nonVisibleColumns = columns . Select ( ( x , idx ) => x . Visible ? - 1 : idx ) . Where ( x => x > - 1 ) . ToArray ( ) ;
234234 var nonSearchableColumns = columns . Select ( ( x , idx ) => x . Searchable ? - 1 : idx ) . Where ( x => x > - 1 ) . ToArray ( ) ;
235235 var mRenderColumns = columns . Select ( ( x , idx ) => string . IsNullOrEmpty ( x . MRenderFunction ) ? new { x . MRenderFunction , Index = - 1 } : new { x . MRenderFunction , Index = idx } ) . Where ( x => x . Index > - 1 ) . ToArray ( ) ;
236236 var CssClassColumns = columns . Select ( ( x , idx ) => string . IsNullOrEmpty ( x . CssClass ) ? new { x . CssClass , Index = - 1 } : new { x . CssClass , Index = idx } ) . Where ( x => x . Index > - 1 ) . ToArray ( ) ;
237+
238+
237239
238240 var defs = new List < dynamic > ( ) ;
239241
@@ -254,6 +256,15 @@ private static string ConvertColumnDefsToJson(IEnumerable<ColDef> columns)
254256 defs . Add ( new { className = CssClassColumn . CssClass , aTargets = new [ ] { CssClassColumn . Index } } ) ;
255257 }
256258
259+ for ( var i = 0 ; i < columns . Length ; i ++ )
260+ {
261+ if ( columns [ i ] . Width != null )
262+ {
263+ defs . Add ( new { width = columns [ i ] . Width , aTargets = new [ ] { i } } ) ;
264+ }
265+ }
266+
267+
257268 if ( defs . Count > 0 )
258269 return new JavaScriptSerializer ( ) . Serialize ( defs ) . Replace ( "\" %" , "" ) . Replace ( "%\" " , "" ) ;
259270
0 commit comments