之前修改后者往Matrix添加一行記錄的時(shí)候,都是用
jsx3.xml.Entity insertRecord(objRecord : Object<String, String>, strParentRecordId : String, bRedraw : boolean)或者void insertRecordNode(objRecordNode : jsx3.xml.Entity, strParentRecordId : String, bRedraw : boolean)方法。
通過對(duì)兩個(gè)方法的參數(shù)或者對(duì)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.可以看出只是一個(gè)是對(duì)象,而后者則是一個(gè)Entity 。而這兩種方法的最后一個(gè)參數(shù)也有說明:bRedraw – if true or null, the on-screen view of this object is immediately updated to reflect the additional record.
但這時(shí)候遇到了一個(gè)就是更新單元格的數(shù)據(jù),而之前我們做的時(shí)候都是通過jsx3.xml.Entity getRecordNode(strRecordId : String)方法把當(dāng)前選上的記錄先獲取到。然后再通過jsx3.xml.Entity setAttribute(strName : String, strValue : String)方法設(shè)置單元值。最后還要利用void repaintData()方法刷新數(shù)據(jù)。這樣才可以把修改后的值顯示出來。其中對(duì)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.
而最近看到了另一個(gè)方法: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.
另注:獲取單行記錄還有另一個(gè)方法:Object<String, String> getRecord(strRecordId : String);他與getRecordNode返回的類型不同,他返回的是對(duì)象。我們可以通過說明: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.看出。他是一個(gè)克隆,也就是對(duì)其操作并不影響jsx3.xml.CDF里面的值。而當(dāng)修改getRecordNode返回的Entity將會(huì)影響到jsx3.xml.CDF。getRecordNode的說明中就可以體現(xiàn)這一點(diǎn)。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.這里還說到了另一個(gè)方法redrawRecord(strRecordId, jsx3.xml.CDF.UPDATE); 這就相當(dāng)與單行刷新。當(dāng)然比使用void repaintData()方法刷新數(shù)據(jù)好的多了。
當(dāng)然還有別的方法。例如Matrix里面還有一個(gè)實(shí)現(xiàn)就是: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.以及對(duì)void redrawRecord(strRecordId : String, intAction : int, bRecurse : boolean)的實(shí)現(xiàn)。
所以當(dāng)修改單行的單元格數(shù)據(jù)的時(shí)候看個(gè)人愛好了。
posted on 2007-05-24 20:44
周銳 閱讀(337)
評(píng)論(0) 編輯 收藏 所屬分類:
TIBCO