// I'm inside init() function here demandTable.commentEditor = new Ext.form.HtmlEditor({ id:'demandMyComment', name: 'mycomment', hideLabel: true, enableFontSize: false, enableLists: false, enableSourceEdit: false, cleanHtml: function (html) { // The tag is not supported in the grid control, but the tag is supported for BOLD. html = html.replace(//g, ""); html = html.replace(/<\/STRONG>/g, "<\/B>"); // The tag is not supported in the grid control, but the tag is supported for Italics. html = html.replace(//g, ""); html = html.replace(/<\/EM>/g, "<\/I>"); // This Forces a new window to popup when hyperlink is added. html = html.replace(/$collaboration_discussiongridexpander_title:
{comment}
' ) }); demandTable.discussionGridCtrl = new Ext.grid.GridPanel({ ds: demandTable.commentsDS, cm: new Ext.grid.ColumnModel([ commentExpander, {id:'commentTitle', header: '$collaboration_commentcolumn_header', width: 350, sortable: true, dataIndex: 'commentTitle'}, {header: '$collaboration_usercolumn_header', width: 130, sortable: true, dataIndex: 'user'}, {header: '$collaboration_timecolumn_header', width: 110, sortable: true, dataIndex: 'timeStampDisplay'} ]), loadMask: {msg:'$table_load_msg'}, frame:false, collapsible: false, animCollapse: false, title:'$collaboration_discussiongrid_title', layout:'fit', width:635, height: 195, autoScroll: true, headerAsText:true, renderTo: demandTable.collaborationTabPanel, enableHdMenu: false, style:'padding-top:10px;', plugins: commentExpander }); var btnAddComment = new Ext.Button ({ id: 'addButtonMyComment', #if (!$canManageDemandItems && !$canMakeRequests) disabled: true, #end text: '$collaboration_addcomment_btn', handler: function () { var InsertRecord = Ext.data.Record.create( {name: 'commentId'}, {name: 'commentTitle'}, {name: 'comment'}, {name: 'userId'}, {name: 'user'}, {name: 'timeStamp'}, {name: 'timeStampDisplay'} ); var newComment = demandTable.commentEditor.getValue(); if (newComment == '') { Ext.MessageBox.show({ title: '$collaboration_errordlg_title', msg: '$collaboration_errordlg_msg', buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR }); } else { // cleans up the comment title to display plain text in grid row. var newCommentTitle = newComment.replace(/
/g, " "); newCommentTitle = newCommentTitle.replace(/ /g, ""); newCommentTitle = newCommentTitle.replace(/<[^<>]+>/g, ""); if (newCommentTitle.length > 60) { newCommentTitle = newCommentTitle.slice(0,60)+ '...'; } var currentTimeStamp = TimeManager.getAdjustedTime(); var commentRecord = new InsertRecord({ commentId: '', commentTitle: newCommentTitle, comment: newComment, userId: '$currentUserId', user: '$currentUser', timeStamp: currentTimeStamp, timeStampDisplay: TimeManager.convertToLocaleDateTime(currentTimeStamp) }); demandTable.commentsDS.insert(0,[commentRecord]); demandTable.commentEditor.setValue(""); } } }); demandTable.collaborationTabPanel = new Ext.Panel({ width: 650, height: 371, layout: 'form', frame:true, labelAlign: 'top', waitMsgTarget: true, items: [ demandTable.commentEditor, btnAddComment, demandTable.discussionGridCtrl ] });