ListView refreshing

Hello

I work with ListView to display a list of contacts, some online and offline. I want contacts who are online to appear at the top of my list, and they might come online later so that they will be put to the top of the list, if they come online later.

I have a working solution, but it is not satisfactory because it requires a complete refresh of my listview and there may be times when a lot of contacts appear online at the same time so that it looks a little messy when there are muliple refreshes plays one after another.

Is it possible to move an element from one place in the list to the top of the list as needed without having to do a complete refresh?

Currently what I did to achieve a workable solution is simply to remove the contact of a QList variable - entireList can add or insert new (depending on whether the contact is online or not).

I then erase my datamodel and add my entireList data back in the datamodel and emit itemsChanged (bb::cascades:ataModelChangeType::AddRemove) of my datamodel.

It does the job, but I hope that there is a cleaner way to do it.

Anyone with a bit of advice please?

Take a look at the example of AsynchronousDataLoading for the implementation, unfortunately this is the way to simple plug-and-play and so will take a little work on the side IndexMapper of pointers to fit your project...

http://developer.BlackBerry.com/native/documentation/Cascades/UI/lists/asynch_data.html

If you are fairly confident with pointers and binary research, it should be pretty easy for you.

Tags: BlackBerry Developers

Similar Questions

  • How to refresh the ListView

    I have try change item in the ListView. But ListView refreshed only after add a new point.
    How can I refresh the ListView?
    My code:
         @Override
         public void start(Stage stage) throws Exception
         {
              buildForm(stage);
              stage.show();
         }
         //--------------------------------------------
         void buildForm(Stage stage)
         {
              BorderPane root = new BorderPane();
              Scene scene = new Scene(root, 800, 650);
              stage.setScene(scene);
              
              items.add(new SimpleStringProperty("1"));
              i++;
              items.add(new SimpleStringProperty("Line" + i));
              i++;
              list.setItems(items);
              root.setCenter(list);
              
              HBox buttons = new HBox();
              root.setBottom(buttons);
              
              Button buttonChange = new Button("Change");
              buttonChange.setOnAction(new EventHandler<ActionEvent>()
                        {
                             public void handle(ActionEvent event)
                             {
                                  String value = items.get(0).get();
                                  if(value.length() == 1)
                                       items.get(0).setValue("-1");
                                  else
                                       items.get(0).setValue("1");
                                  //not refresh
                             }
                        });
              
              Button buttonAdd = new Button("Add item");
              buttonAdd.setOnAction(new EventHandler<ActionEvent>()
                        {
                             public void handle(ActionEvent event)
                             {
                                  items.add(new SimpleStringProperty("Line" + i));
                                  i++;
                                  //refresh
                                  
                             }
                        });
              buttons.getChildren().addAll(buttonChange, buttonAdd);
              
         }

    ?

  • update a ListView when dataModel changes

    Hi gang,.

    I have a defined GroupDataModel as a Q_PROPERTY a class custom C++.

    I join this GroupDataModel a ListView in QML.

    Make changes to the items in the GroupDataModel by pulling on the elements in the model in a ListOfObjects.

    I can see that the changes are effective for exit qDebug(), but the ListView refresh.

    Q_PROPERTY, I have a NOTIFY signal defined (on onItemListChanged), and in the function where I edit items, I emit this signal (emt onItemListChanged(), but the ListView does nothing.)

    How can I get the updated list?

    Here is the function update the items.

    void WorkManager::updateKey(QString newKey, int whichObject) {
    
        if (!newKey.isNull()) {
            QList  myObjects = m_model->toListOfObjects();
                    Task * myTask = (Task *) myObjects[whichObject];
                    qDebug() << "object is : " << myObjects[whichObject];
                    qDebug() << "object key is: " << myTask->key();
                    myTask->setNotifyKey(newKey);
                    emit onItemListChanged();
                    qDebug() << "modified object key is : " << myTask->notifyKey();
        }
    
    }
    

    do I need to connect a signal to a slot somewhere?  I thought that this will be done automatically.

    THX,

    J

    Ah, I see. I really have to update the model to get this fire its signals.

    Add this:

                 QVariantList indexPath = m_model->findExact(myTask);
                    qDebug() << "WorkManager::updateItem(), indexPath is : " << indexPath;
                    m_model->updateItem(indexPath, myTask);
    

    makes work.

    Here is the full function:

    void WorkManager::updateKey(QString newKey, int whichObject) {
    
        if (!newKey.isNull()) {
            QList  myObjects = m_model->toListOfObjects();
                    Task * myTask = (Task *) myObjects[whichObject];
                    qDebug() << "object is : " << myObjects[whichObject];
                    qDebug() << "object key is: " << myTask->key();
                    myTask->setNotifyKey(newKey);                                QVariantList indexPath = m_model->findExact(myTask);                                qDebug() << "indexPath is : " << indexPath;                                m_model->updateItem(indexPath, myTask);
                    qDebug() << "modified object key is : " << myTask->notifyKey();
        }
    
    }
    
  • How to solve this query in database using sqlite phone gap

    am facing a problem in recent days. The problem is database. In fact, I create the mane database 'casepad '. Then I created a table because the database 'table of cases' have (ID, name, date). Now I insert the value on this table. When inserting I also create a name ("casename") .mean table if I insert the value of the case table (1, 'AB', 2/13). Then I create table AB. Now I need to get the value of the case table (I am) but I need to count the number of items in another table (AB). Here, I had to try it.

    function onDeviceReady() {
    
        db = window.openDatabase("Casepad", "1.0", "Casepad", 200000);
    
    db.transaction(getallTableData, errorCB);
    
    }
    
    function insertData() {
        db.transaction(createTable, errorCB, afterSuccessTableCreation);
    }
    
    //createtableandinsertsome record
    function createTable(tx) {
        tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName  TEXT unique NOT NULL ,CaseDate INTEGER ,TextArea TEXT NOT NULL)');
    
        tx.executeSql('INSERT OR IGNORE INTO CaseTable(CaseName,CaseDate,TextArea) VALUES ("' + $('.caseName_h').val() + '", "' + $('.caseDate_h').val() + '","' + $('.caseTextArea_h').val() + '")');
    
    }
    //function will be called when an error occurred
    function errorCB(err) {
        navigator.notification.alert("Error processing SQL: " + err.code);
    }
    
    //function will be called when process succeed
    function afterSuccessTableCreation() {
        console.log("success!");
        db.transaction(getallTableData, errorCB);
    }
    
    //select all from SoccerPlayer
    function getallTableData(tx) {
        tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB);
    }
    
    function querySuccess(tx, result) {
        var len = result.rows.length;
        var t;
        $('#folderData').empty();
        for (var i = 0; i < len; i++) {
    
            $('#folderData').append(
                    '
  • ' + '' + '' + '

    ' + result.rows.item(i).CaseName + t+'

    ' + '

    ' + result.rows.item(i).TextArea + '

    ' + '

    ' + result.rows.item(i).CaseDate + '

    ' + '' + i + '
    ' + '
    '+'
  • ' ); } $('#folderData').listview('refresh'); }

    Instend of show the value of 'i' in the view list, I need to show how many element in the table. I have to call synchronize because I call a query that counts the number of elements to 'result.rows.item (i). CaseName"this item... ?

    Hello

    If I understand correctly, you are looking for a SQL statement that you will get the count for the number of items in the table AB? If so, this can be useful:

    http://www.w3schools.com/SQL/sql_func_count.asp

    Please let me know if you have any other questions.

  • Filebrowsing PlayBook with Webworks/PhoneGap

    I'm pass Air/Actionscript to WebWorks and a bit of trouble. I tried several tutorials browser for the file Phonegap and samples I found on the web, but they do not work on the Playbook. I added the permission to access_shared to the config. I have a

      and when my application starts it's supposed to load the files and directories in the
        .

        My js is below:

        document.addEventListener("deviceready", onDeviceReady, false);
        function onDeviceReady(){
        window.requestFileSystem(
        LocalFileSystem.PERSISTENT,
        0, onFileSystemSuccess, fail
        );
        }
        
        function onFileSystemSuccess(fileSystem) {
        // Create some test files
        fileSystem.root.getDirectory("myDirectory",
        { create: true, exclusive: false },
        null,fail);
        fileSystem.root.getFile("readthis.txt",
        { create: true, exclusive: false },
        null,fail);
        var directoryReader = fileSystem.root.createReader();
        // Get a list of all the entries in the directory
        directoryReader.readEntries(success,fail);
        }
        
        function success(entries) {
        var i;
        var objectType;
        for (i=0; i

        ' + entries[i].name + '

        ' + entries[i].toURI() + '

        Type: ' + objectType + '

        '); } $('#directoryList').listview("refresh"); } function fail(error) { alert("Failed to list directory contents: " + error.code); }

        I found the example Dir in kickensink showed me what I needed to know.

  • Attempts to display the release of jQuery to simulate a table - need help

    Hi all

    using javascript for the application database that brings back a result of 10 or 20 results. I am trying to simulate a tabular presentation for the result, but it does not work well. Show the lines - but not inside the table as shown below and eventually the date above display table headers - not after the headers...

    I want to get this to work if possible

    No idea how to put in place if it works like a table html correctly?

    Thanks in advance - DAVE

    $(données, fonction (clé, valeur) {} .each)

    Console. Log ("item", key, value);

    output += '< tr > "+.

    '< td width = '75' >' + value. First + "< table > ' +.

    '< td width = "150" >' + value. Last + "< table > ' +.

    '< td width = '25' >' + value.phone + '< table > ' +.

    '< td width = '25' >' + value.email + '< table > ' +.

    + "< /tr >";

    });

    $('#list').html (output);

    $('#list').listview ("refresh");

    });

    <!-table then... ->


    < table border = "1" cellspacing = "2" cellpadding = "2" >

    <!--> the table header

    < b >

    < width = '75' th > first < table >

    < width th = "150" > last < table >

    < width = '25' th > phone < table >

    < width = '25' th > e-mail < table >

    < /tr >

    <! - hoping that it would create domestic lines - but eventually top the table header lines - >

    < div id = 'list' data-role = "listview" > < / div >

    < /table >

    You can't just dump a div into a table like this. Replace the div the tbody tag.

    first

    Last

    Phone

    E-mail

  • How to refresh the listview that is in another function

    Hi all,
    I have a problem with a refreshing of the listview.

    I have 3 features in the application, let's say 'feature A' 'feature B' and 'C'.

    I also have 2 tables and sqlite db (local) .and 1 view their names are 'A table', 'table B' and 'see C.

    View C is like this:

    create view C as

    Select a.oneColumn

    Table has a

    Union

    Select b.oneColumn

    Table B b;

    Each function has the main amx.page and each of them has listview values from the (local) sqlite DB.


    According to A, I can add new row to the database (line update or delete) and the list is updated with the help of the "ProviderChangeSupport".

    Same thing happens in the function (B) everything is ok so far. But according to C, there also listview. When I delete operation or update functionality or B.

    the listview in C function is not updated.


    I hope you all can easily understand the problem and help me with the solution. Oracle Mobile Application Framework.

    Hello

    you need to reset a feature - navigating it--you want to ensure the functionality and so refreshes the view. The change of supplier support works in the ClassLoader (feature film) it is issued to. You can use a listener to refresh the controls collection of data used by a list, but it does not work automatically.

    Frank

  • How to refresh the Listview after adding a new item

    Hello

    I have the following list:

     ListView {
                                        id: channelsList
    
                                        dataModel: categoryModel
    
                                        listItemComponents: [
                                            ListItemComponent {
                                                type: "item"
                                                StandardListItem {
                                                    title: ListItemData.name // Channel name
                                                    imageSource: ListItemData.imageFile
                                                    status: ListItemData.id
    
                                                    id: channelItemId
    
                                                    contextActions: [
                                                        ActionSet {
                                                            //title: contentView.title
                                                            ActionItem {
                                                                title: "Add to Favorites"
    
                                                                onTriggered: {
                                                                    console.log(ListItemData.id + " will be added to the Favorites");
                                                                    //categoryModel.addFavorite(ListItemData.name, ListItemData.imageFile, ListItemData.id);
                                                                    channelItemId.ListItem.view.viewTriggered(ListItemData.name, ListItemData.imageFile, ListItemData.id);
                                                                }
    
                                                            }
    
                                                        }
                                                    ]
                                                }
                                            }
                                        ]
    
                                        onTriggered: {
                                                var chosenChannel = dataModel.data(indexPath);
                                                console.log("indexPath: " + indexPath);
    
                                                var playingPage = playpagedef.createObject();
    
                                                playingPage.chname = chosenChannel.name;
                                                playingPage.cid = chosenChannel.id;
                                                playingPage.init();
    
                                                Qt.nav.push(playingPage);
    
                                        }
    
                                        attachedObjects: [
                                            // The bucket categoryModel is a non visible object so it is set up as an attached object.
                                            // The categoryModel itself is a QListDataModel defined in categorymodel.h and registered
                                            // as a type in the creation of the application.
                                            CategoryModel {
                                                id: categoryModel
                                                // The path to the JSON file with initial data, this file will be moved to
                                                // the data folder on the first launch of the application (in order to
                                                // be able to get write access).
                                                jsonAssetPath: "models/channels.json"
    
                                                // The filtering is initially set to "Category 1" to show category channels
                                                filter: label.text
                                            },
    
                                            ComponentDefinition {
                                                id: playpagedef
                                                source: "PlayingPage.qml"
                                            }
                                        ]
    
                                        function viewTriggered(name, imageFile, id)
                                        {
                                            categoryModel.addFavorite(name, imageFile, id);
                                            categoryModel.clear();
                                        }
    
                                    }
    

    and the categoeymodel.h is as follows:

    #ifndef _CATEGORYMODEL_H
    #define _CATEGORYMODEL_H
    
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::data;
    
    // The category categoryModel is based on the QListDataModel template, which in turn
    // implements the abstract DataModel class.
    typedef bb::cascades::QListDataModel CategoryListModel;
    
    /* CategoryModel Description:
     *
     * CategoryModel class for the Category List application, the data categoryModel
     * reads and write from a JSON file that keeps all item data
     * for the list.
     */
    class CategoryModel: public CategoryListModel
    {
    Q_OBJECT
    
    Q_PROPERTY(QString filter READ filter WRITE setFilter NOTIFY filterChanged)
    
    Q_PROPERTY(QString jsonAssetPath READ jsonAssetPath WRITE setJsonAssetPath NOTIFY jsonAssetPathChanged)
    
    public:
        /**
         * Constructor that sets up the recipe
         * @param parent The parent Container, if not specified, 0 is used
         */
        CategoryModel(QObject *parent = 0);
        ~CategoryModel();
    
        QString filter();
    
        void setFilter(const QString filter);
    
        QString jsonAssetPath();
    
        void setJsonAssetPath(const QString jsonAssetPath);
    
    signals:
    
        void filterChanged(QString filter);
    
        void jsonAssetPathChanged(QString jsonAssetPath);
    
    public slots:
        void addFavorite(QString channelName, QString channelImageFile, int channelId);
    
    private:
        bool jsonToDataFolder();
    
        // Property variables
        QString mFilter;
        QString mJsonAssetsPath;
        QString mJsonDataPath;
    
        // A list containing all data read from the JSON file
        QVariantList mData;
    
        //Invocation variables
        bb::cascades::Invocation* mInvocation;
    };
    
    #endif // ifndef _CATEGORYMODEL_H
    

    My problem is that the listview is not get automatically updated when a new item is added to the datamodel (a favorite channel is added). I have to exit the application and restart to see the updated list.

    categoryModel.addFavorite(name, imageFile, id);
    categoryModel.clear();
    

    categoryModel.clear ();

    does not work. I get:

    Asset: / / / hand. QML:180: TypeError: result of expression 'categoryModel.clear' [undefined] is not a function.

    I would like to know how to achieve using approach "more correct".

    QListDataModel does not expose its internal storage directly. It is possible to reconstruct the map by performing an iteration in a loop (with the help of data() and size() methods), the dataModel entries:

    http://developer.BlackBerry.com/Cascades/reference/bb__cascades__qlistdatamodel.html

    but I don't see how this could help. If the filtered data is changed, it must be merged with the original sort data.

    Why the original approach has not worked?

    I could not understand from the description appearance of the interface user, please post a screenshot if possible.

  • Is to refresh (listview) still not supported?

    Hi all

    I remember there is a thread discussing this, it does not appear supported right here. Now it is already beta4, this feature is supported? Or is there a work around for this feature by myself?

    Thank you

    Dong

    you need to implement yourself, here's the trick:

    (1) use visual leader of the ListView

    (2) get position updates using the LayoutUpdateHandler: https://developer.blackberry.com/cascades/reference/bb__cascades__layoutupdatehandler.html

  • DataSource is not refresh a runtime

    Hello

    When I load a page for the first time, it loads all the perfect data. But the data source is not refresh the data when executing, how to refresh listview when I load a page, then by restarting each time the application of others.

    I used the code below, but does not during execution.

      onCreationCompleted: {
            dataSource.load();
    }
    

    you decide when it is refreshed... onCreationCompleted is called only when the page is created, which can be the case every time (for example where the Prosecutor tabbedpanne).

    so, as a method of inrush current in the case of signals:

    onTriggered

    onTopChanged

    onClick

  • How to recharge a ListView when an item is deleted or changed?

    So I have a ListView in a Page that lists the files.  And the selected files are sometimes renamed or deleted on the triggering of action items, how to refresh the ListView to reflect these changes?

    I would refresh my data model during the outbreak of the follow-up action. It would be just a matter of ListView redisplay with the new data model data.

    It is not in a Navigation pane so I can't push a ComponentDefinition.

    Hello

    Have you tried clearing the datamodel and re - insert the data into it.

    Clear() - http://developer.blackberry.com/cascades/reference/bb__cascades__groupdatamodel.html#function-clear

    insertList() - http://developer.blackberry.com/cascades/reference/bb__cascades__groupdatamodel.html#function-insert...

  • Contacts ListView load time?

    Hello!

    Home page of the application is a list of all the contacts stored on the device.  I recover contacts using the () ContactService contacts (filters); For the some 200 + contacts it takes time to display the loading list. So I used a mechanism for paging as suggested. But the listview still takes a while to load (it seems to me that updates of the ListView when all contacts are loaded by opposition to refresh with new paged contacts).

    It is, unsurprisingly, worse with more contacts. For example, for 2 k + contacts, it takes about 2. a few seconds to load.

    Here's the code that loads the contacts:

        mModel->clear();
    
        const int maxLimit=200;
    
        ContactListFilters filter;
        filter.setLimit(maxLimit);
    
        ContactService service;
        QList contacts;
    
        do
        {
           contacts=service.contacts(filter);
    
           loadContacts(contacts);
    
            if (contacts.size() == maxLimit)
            {
                filter.setAnchorId(contacts[maxLimit-1].id());
            }
            else
            {
                break;
            }
        } while (true);
    

    and, loadContacts (QList):

    void ContactsView::loadContacts(QList contacts){
    
        QVariantList list;
    
        foreach(Contact c,contacts){
    
                   QVariantMap map;
                   map["fName"]=c.displayName();
    
                   QString path;
    
               if(c.smallPhotoFilepath().isEmpty()){path="asset:///images/contact.png"; }
                   else { path="file://"+c.smallPhotoFilepath(); }
    
                   map["photo"]=path;
                   list.push_back(map);
                }
    
                mModel->insertList(list);
    
    }
    

    Any suggestions? What I am doing wrong?

    UI will not get updated until c code ++ is done, only way around, I have found is to put the code c ++ inside its own thread and send signals with the partial result every now and then, so for your application, each 200 contacts he would send a signal with these contacts in a dataModel or a QVariantMap.

  • indicator problem ListView and activity

    Hi, I was playing around with the sample application address book so that I have included a button to re-populate the list view. It takes a few seconds, that's why I've included an indicator of activity runs while the list view is being filled.

    The activity indicator is supposed to start when the button is pressed and stop when the display of the list has been entered.

    Now, my problem is that the activity indicator seems to start when the display of the list has been populated (it just starts and stops in a Flash). I have also included a header which changes the onbuttonclicked text to check if that was the problem-indicator of activity but same thing happening (text only changes after listview is filled). The list view appears to stop all operations until it was settled.

    What is the cause and how can I solve this problem? Thank you.

    onButtonClicked {}
    change the header text
    start the activity indicator
    fill listview
    }

    Then in c ++ after m_model-> insert (map) I emit a stop to the activity indicator signal.

    Indicator text and header activity does not change until the listview has been briefed.

    as the list of all the opinions of the population occurs on the event thread indicator gets no time to do things.
    If you would like to fill in the asynchronous list, it should work as expected.

    as a sidenote: have a look to refresh the headers, they are often used to reload a list.

  • ListView checkBox

    Hello

    So, I have a ListView with a ListItemComponent that has a custom line.

    Inside this custom line, I have a checkbox that I can click without triggering the selection of lines.

    How will I know which line has been clicked (or the information that is there on the line)

    Is this possible with qml?

    {Of container
            
    {To ListView
    ID: list
    layout: {StackListLayout}
    headerMode: ListHeaderMode.Sticky
    }

    dataModel: dataModel
    listItemComponents:]
    {ListItemComponent}
    type: 'point '.
    CustomItem {}

    an item personalized with a checkbox which can be archived power

    ......
    }

    Thank you guys

    The best way is to add the checked value directly in your model. Otherwise, you lost you checked during the refresh of the ListView. So, if you use an ArrayDataModel with a property key 'checked ':

    So, in your {box

    onChecked: ListItemData.checked = false;

    }

  • How update the "ListItemComponent" view in ListView?

    Hi all

    I do samples of listview. Is it possible to refresh the view a list (ListItemComponent). If so, please provide guidance or a link.

    Thanks in advance.

    If your data are dynamic, it's like BBSJdev said, the changes made to the model. And if the template is changed, you must react accordingly with a trigger

Maybe you are looking for

  • Flash video not working does not, despite all the previous solutions

    On some embedded flash video sites do not work properly. Strangely enough, youtube works very well. I've browsed the forum and have tried the following solutions, none doesn't seem to work: -Disable Realplayer (which is not installed on my computer)-

  • EliteBook 8440p (ENERGY STAR): need driver for laptop HP EliteBook 8440p (ENERGY STAR)

    I need to set: 1 card reader 2 - bluetooth 3 sound

  • Debug vs out - why should I use one over the other

    Hi all I have always understood that in the preparation for the final release software and delivery that this should be done using the Release configuration. It's the way that other companies offer their software, so it just makes intuitive sense to

  • My laptop is * USELESS *.

    Then, I had originally Windows Vista on my laptop that comes with it. Some time ago I have upgraded to Windows 7... I used a MSDN key, now I can't use this key, it turned out to be non-genuine, I decided to use Rescue and Recovery to restore my syste

  • Format of the axis

    I'm having a problem with the Push Notifications from my server. I think it has to do with the PIN device, but I'm not sure. Basically I can send notifications fine if I use . If I try to use the PIN device, I get the following error: The PIN device