private static void updateCache(ListGrid grid, Record record, DSOperationType opType) {
	DSRequest request = new DSRequest();
	request.setOperationType(opType);

	DSResponse response = new DSResponse();
	ListGridRecord lgRecord = new ListGridRecord();
	for (String attrName: record.getAttributes()) {
		lgRecord.setAttribute(attrName, record.getAttributeAsObject(attrName));
	}
		
	response.setData(new ListGridRecord[]{ lgRecord });
	response.setOperationType(opType);
	response.setStatus(0);

	if (opType == DSOperationType.ADD) {
		ResultSet originalResultSet = grid.getOriginalResultSet();
		int rowCount = originalResultSet.getLength();
		request.setStartRow(rowCount);
		request.setEndRow(rowCount + 1);
		response.setStartRow(rowCount);
		response.setEndRow(rowCount + 1);
		response.setTotalRows(rowCount + 1);
	}

	PMTableDataSource dataSource = (PMTableDataSource)grid.getDataSource();
	dataSource.updateCaches(response, request);
	
	grid.markForRedraw();
}
