none
[JSGrid] Error in jsgrid.debug.js RRS feed

  • Question

  • Hello,

    I am working on a JSgrid dev for SharePoint & Project Server 2010. When I switch from a hierarchical view to a normal view, I get the following error from jsgrid.debug.js:

    Microsoft.JScript runtime error: 'columns.GetColumnByKey(...)' is null or not an object.

    Here's the client code :

    GridManager = function () {
    
    	// Public vars (reachable during execution).
    	this.JSGridControl = null; 	// Variables for the JSGrid control instance and the grid properties
    	this.Properties = null; 	// Variables for the JSGrid control instance and the grid properties
    	this.JSGridControlInitializer = null;
    
    	// Private vars (unreachable during execution).
    	var _jsGridParams; 		// Variable for the JSGrid params
    	var _dataSource; 		// Variable for the grid data source
    	var _tableCache; 		// Variable for the grid data source cache
    	var _projectStatusID; // Variable for the project status
    	var _orderByColumnName; // Variables for sorting.
    	var _isDescending; 		// Variables for sorting.
    
    	// Define Filter/Grouping/Detailed view vars + set default values.
    	this.DetailedView = false;
    	this.Grouping = false;
    	this.CurrentFilterId = null;
    	this.GroupingField = null;
    	this.Grouping = false;
    
    	this.DataSource = function () {
    		return _dataSource;
    	};
    
    	this.Init = function (jsGridControl, initialData, props) {
    		this.JSGridControl = jsGridControl;
    		this.JSGridControlInitializer = jsGridControl;
    		this.Properties = props;
    
    		// Set default view.
    		this.DetailedView = props.detailedView;
    		this.Grouping = props.grouping;
    		this.GroupingField = props.groupingField;
    		this.CurrentFilterId = props.defaultFilterId;
    
    		// get the initial data.
    		var args = Sys.Serialization.JavaScriptSerializer.serialize({
    			Command: commands.GetData,
    			DetailedView: GM.DetailedView,
    			Grouping: GM.Grouping,
    			GroupingField: GM.GroupingField,
    			FilterId: GM.CurrentFilterId
    		});
    
    		// Client calls the display callback.
    		eval(callbacks.displayCallback);
    	}
    	
    	// ...
    	
    	this.Callback_GetData = function (data) {
    
    		GM.HideLoadingDiv();
    
    		// Show data in the grid.
    		if (data != null && data != '') {
    			// First deserialisation.
    			var responseData = Sys.Serialization.JavaScriptSerializer.deserialize(data);
    
    			if (responseData.ErrorMessage != null && responseData.ErrorMessage != '') {
    				// Error occured.
    				alert(responseData.ErrorMessage);
    			} else {
    
    				// Deserialise once more to get the JsonGrid object.
    				_gridData = SP.JsGrid.Deserializer.DeserializeFromJson(responseData.JsonGrid);
    				if (!_dataSource)
    					_dataSource = new SP.JsGrid.StaticDataSource(_gridData);
    				else
    					_dataSource.LoadSerializedData(_gridData);
    				_jsGridParams = _dataSource.InitJsGridParams();
    
    
    				// Sets the table cache in the _tableCache variable.
    				_tableCache = _jsGridParams.tableCache;
    
    				// OLD VERSION
    				if (!GM.JSGridControl.IsInitialized())
    					GM.JSGridControl.Init(_jsGridParams);
    				else
    					GM.JSGridControl.SetTableView(_jsGridParams.tableViewParams);
    
    				GM.JSGridControl.SetSplitterPosition(435);
    				GM.JSGridControl.DisableEditing();
    			}
    		}
    	}
    	
    	// ...
    }
    And here's my server code :
    		public string GetCallbackResult()
    		{
    			CallbackResult cbr = new CallbackResult();
    			try
    			{
    				switch (_callbackArgs.Command)
    				{
    					case Commands.GetData:
    						cbr = GetData();
    						break;
    
    					default:
    						throw new NotImplementedException();
    				}
    			}
    			catch (Exception ex)
    			{
    				cbr.ErrorMessage = ex.ToString();
    			}
    			return Utils.Jsonify(cbr);
    		}
    ...
    		private CallbackResult GetData()
    		{
    			DateTime start = DateTime.Now;
    			CallbackResult cbr = new CallbackResult();
    			try
    			{
    				// Set vars.
    				this.DetailedView = _callbackArgs.DetailedView;
    				this.Grouping = _callbackArgs.Grouping;
    
    				Modes displayMode = this.GetMode(_callbackArgs.DetailedView, _callbackArgs.Grouping);
    
    				// get selected filter ...
    				Filter selectedFilter = null;
    				if (!string.IsNullOrEmpty(_callbackArgs.FilterId))
    				{
    					selectedFilter = this.GetSelectedFilter(new Guid(_callbackArgs.FilterId));
    				}
    
    				// Retrieve the JSGridDisplay corresponding to the current mode.
    				JSGridDisplay currentJSGridDisplay = GetJSGridDisplay(displayMode);
    				List<GridColumn> gridColumns = GetGridColumns(currentJSGridDisplay);
    
    				// Build flat data
    				DataTable data = this.BuildGanttData(currentJSGridDisplay, selectedFilter, this.DetailedView, this.Grouping, _callbackArgs.GroupingField);
    
    				// Create a grid serializer to connect to data
    				GridSerializer gds = new GridSerializer(
    					SerializeMode.Full,
    					data,
    					this.KeyColumn,
    					new FieldOrderCollection(new String[] { Columns.ProjectName }),
    					GetGridFields(data),
    					//GridUtilities.GetGridColumns(this.DetailedView, this.Grouping)
    					gridColumns // GetGridColumns(displayMode)
    				);
    
    				// Enable hierarchy
    				if (this.DetailedView || this.Grouping)
    				{
    					gds.EnableHierarchy(null, Columns.TaskParentUID, Columns.ProjectName, false);
    					gds.SetHierarchyStateExpandedToLevel(0);
    				}
    
    				// Get earliest and latest dates of data
    				var query = from row in data.AsEnumerable()
    							select row.Field<DateTime?>(Columns.ProjectStartDate);
    
    				DateTime? earliestDate = (query.Count() > 0) ? query.Min<DateTime?>() : DateTime.Now.AddDays(-30);
    				DateTime? latestDate = (query.Count() > 0) ? query.Max<DateTime?>() : DateTime.Now.AddDays(30);
    
    				// Enable Gantt chart.
    				gds.EnableGantt(earliestDate.Value, latestDate.Value, GanttUtilities.StyleInfo, Columns.ProjectStartDate);
    
    				// set the JsonGrid property.
    				cbr.JsonGrid = gds.ToJson(new Serializer());
    			}
    			catch (Exception ex)
    			{
    				cbr.ErrorMessage = ex.ToString();
    			}
    
    			TimeSpan span = DateTime.Now.Subtract(start);
    			if (DebugMode) TraceProvider.LogFormattedPerf("BasicInfo.GetData() took [{0}]ms. (including SQL exec time).", span.ToString());
    			return cbr;
    		}

    I hope someone can help me out on this!

    Have a nice day


    • Edited by Quentin V Friday, May 17, 2013 8:10 AM more code needed
    Friday, May 17, 2013 7:59 AM