0

我有一个objectlistview。我从中删除了一行,然后我想在不删除行的情况下更新列表。我用数据库中的数据填充列表。我尝试了 repopulatelist,但它似乎使用了列表中已经存在的数据。

我想我可以用 clearAll (清除列表)解决它,然后 addobjects 并再次添加数据库。但似乎应该可以只更新列表。这是我的代码:

def deletemeas(self):

    MAid = self.objectma.id
    MAname = self.pagename

    objectsRemList = self.tempmeasurements.GetCheckedObjects()

    print 'objectremlist', objectsRemList
    for measurement in objectsRemList:
        print measurement
        Measname = measurement.filename
        Measid = database.Measurement.select(database.Measurement.q.filename == Measname)[0].id
        deleteMeas = []
        deleteMeas.append(MAid)
        deleteMeas.append(Measid)
        pub.sendMessage('DELETE_MEAS', Container(data=deleteMeas)) #to microanalyse controller
    #here I get the latest information from the database what should be viewed in the objectlist self.tempmeasurements
    MeasInListFromDB = list(database.Microanalysismeasurement.select(database.Microanalysismeasurement.q.microanalysisid == MAid))

    print 'lijstmetingen:', MeasInListFromDB
    #this doesn't work
    self.tempmeasurements.RefreshObjects(MeasInListFromDB) 
4

1 回答 1

0

好吧,这实际上比我想象的要容易......

我添加了这一行:

self.tempmeasurements.RemoveObject(measurement)

所以我首先从我的数据库表中删除了数据,然后我只是删除了我的 objectlistview 中的行。

于 2017-11-17T15:43:46.263 回答