之前修改后者往Matrix添加一行記錄的時候,都是用
jsx3.xml.Entity insertRecord(objRecord : Object<String, String>, strParentRecordId : String, bRedraw : boolean)或者void insertRecordNode(objRecordNode : jsx3.xml.Entity, strParentRecordId : String, bRedraw : boolean)方法。
通過對兩個方法的參數或者對insertRecordNode方法的說明:Inserts a new record into the XML data source of this object. This method is the same as insertRecord() except that its first parameter is of type jsx3.xml.Entity rather than Object.可以看出只是一個是對象,而后者則是一個Entity 。而這兩種方法的最后一個參數也有說明:bRedraw – if true or null, the on-screen view of this object is immediately updated to reflect the additional record.
但這時候遇到了一個就是更新單元格的數據,而之前我們做的時候都是通過jsx3.xml.Entity getRecordNode(strRecordId : String)方法把當前選上的記錄先獲取到。然后再通過jsx3.xml.Entity setAttribute(strName : String, strValue : String)方法設置單元值。最后還要利用void repaintData()方法刷新數據。這樣才可以把修改后的值顯示出來。其中對repaintData解釋是:Paints only the data rows. Call for quick repainting of the data rows when only the source data has changed. Does not recalculate and reprofile the box profile and resulting XSLT. Retains scroll position when possible.
而最近看到了另一個方法:jsx3.xml.CDF insertRecordProperty(strRecordId : String, strPropName : String, strPropValue : String, bRedraw : boolean);而這方法正好解決了單元格值的變化,Inserts a new property into an existing record with jsxid equal to strRecordId. If the property already exists, the existing property value will be updated. If no such record exists in the XML document, this method fails quietly.
另注:獲取單行記錄還有另一個方法:Object<String, String> getRecord(strRecordId : String);他與getRecordNode返回的類型不同,他返回的是對象。我們可以通過說明:Returns an object containing the attributes of a particular CDF record as property/value pairs. The object returned by this method is a copy of the underlying data. Therefore, updates to this object will not affect the underlying data.看出。他是一個克隆,也就是對其操作并不影響jsx3.xml.CDF里面的值。而當修改getRecordNode返回的Entity將會影響到jsx3.xml.CDF。getRecordNode的說明中就可以體現這一點。Returns a record from the XML data source of this object. This returned value is a handle to the record and not a clone. Therefore, any updates made to the returned value with update the XML document of this object. To reflect such changes in the on-screen view of this object, call redrawRecord(strRecordId, jsx3.xml.CDF.UPDATE); on this object.這里還說到了另一個方法redrawRecord(strRecordId, jsx3.xml.CDF.UPDATE); 這就相當與單行刷新。當然比使用void repaintData()方法刷新數據好的多了。
當然還有別的方法。例如Matrix里面還有一個實現就是:void redrawCell(strRecordId : String, objColumn : jsx3.gui.Matrix.Column, bSuppressTriggers : boolean);Updates the on-screen cell to reflect the value in the CDF document to which the cell is mapped.和void redrawMappedCells(strRecordId : String, strAttName : String);Updates the on-screen cell to reflect the value in the CDF document to which the cell is mapped.以及對void redrawRecord(strRecordId : String, intAction : int, bRecurse : boolean)的實現。
所以當修改單行的單元格數據的時候看個人愛好了。
posted on 2007-05-24 20:44
周銳 閱讀(336)
評論(0) 編輯 收藏 所屬分類:
TIBCO