GroupDataModel and append()

Hi all

Why we can not do append() in a GroupDataModel?

In some cases, it would be more useful than insert()...

I have to make it difficult to add an item at the end of my list

Thank you

Drilldown navigation project model import bb.cascades 1.0 Page {container {button {text: 'Add' onClicked: {data var = {'name': 'schutz', 'age': '23'}; model.append (data) ;}}}}}} {{ListView {dataModel: ArrayDataModel {id: template} listItemComponents: [ListItemComponent {Button {text: ListItemData.nom}}]}}}

Tags: BlackBerry Developers

Similar Questions

  • Structuring a QVariantList for GroupDataModel and hierarachy good tree

    I have two QVariantLists that contain the QVariantMaps.

    How to structure the global QVariantList container to be compatible with a GroupDataModel? I am trying to achieve the same hierarchy tree to http://developer.blackberry.com/cascades/reference/index_paths.html. Then I can use indexPaths correctly.

    Thus, for example:

    QVariantList - header1 - listItems

    |

    -2 header - listitems

    What I tried to do this in C++:

    //Should be 'branch' 0
    QVariantList beforeList;
    beforeList.append(beforeMap);
    
    //Should be 'branch' 1
    QVariantList afterList;
    afterList.append(afterMap);
    
    QVariantList mainList;
    mainList.append(beforeList);
    mainList.append(afterList);
    

    This excludes the headers. ListView does not appear but all paths in the index are 0, x.

    Could someone show me in C++ how to create the two branches with their headers?

    Thank you!

    You must use sort fields to sort the list and group by a property of your data

    Then, you will get the headers automatically and you can decide if the header contains the full value, or only the first character

    the order of your list is not serious - GroupDataModel will sort and group for you, and provide header and items.

  • Grouping data via GroupDataModel and DataSource

    Hello

    I'm loading below via a data source, the data correctly loads the XML data structure and the data are displayed in the ListView.

    
      
      
        
          
            3
              4.28
              
                375802
                Civic
                
                  589
                  Honda
                
              
              
                375803
                Accord
                
                  590
                  Honda
                
              
              
                375804
                Camry
                
                  591
                  Toyota
                
              
            
        
      
    
    

    The GroupDataModel & DataSource is set as shown below...

        attachedObjects: [
    
            GroupDataModel
            {
                id: dataModel
    
                // This works and the header is displayed properly by rating
                //sortingKeys: ["rating"] 
    
                // Sorting does not work, and listview header is displayed @ top with empty data
                sortingKeys: ["manufacturer.name"]
                sortedAscending: true
                grouping: ItemGrouping.ByFullValue
            },
    
            DataSource
            {
                id: dataSource
    
                // Load the XML data from a remote data source
                source: "http://www.mydataservice.com/getdata.php"
                query: "/dataresponse/search/results/cars"
                type: DataSourceType.Xml
    
                onDataLoaded:
                {
                    // After the data is loaded, clear any existing items in the data
                    // model and populate it with the new data
                    dataModel.clear();
                    dataModel.insertList(data)
                }
            }
        ]
    

    The listview is defined per below...

    ListView
    {
       id: myListView
       // Associate the list view with the data model that's defined in the
       // attachedObjects list
       dataModel: dataModel
    
       // Sticky header
       layout: StackListLayout { headerMode: ListHeaderMode.Sticky }
    
       listItemComponents: [
    
         ListItemComponent
         {
            type: "item"
    
            // Use a standard list item to display the data in the data
            // model
            StandardListItem
            {
                imageSpaceReserved: false;
                title: ListItemData.car.model
                description: ListItemData.manufacturer.name  + " ID: " + ListItemData.manufacturer.id
            }
         }
       ]
    }
    

    So, in order to be able to group the data by the automaker, I thought that I could just specify the following sort key sortingKeys: ["manufacturer.name"] but it does not work.

    Any suggestions?

    Hi joelajean,

    According to the documentation on this link "In a GroupDataModel, there are only two levels of items". Looking at how your xml file is formatted, I can see that the manufacturer.name is a level deeper than the second level and this is probably why you can not retrieve the item. I suggest that you try to use a XmlDataModel instead of a GroupDataModel or analyze your file xml in two levels of items.

  • listItemComponent, GroupDataModel and a C++ object

    I have a class that returns information about a set of items.

    You have imageSource 2 times. One outside yew, one inside the fi.

    imageSource: {
                                                  if (ListItemData.active) { imageSource = "asset:///images/on.png" ; }
                                                  else { imageSource = "asset:///images/off.png" ; }
                                              }
    

    Try the following line

    imageSource: "asset:///images/" + (ListItemData.active?"on":"off") + ".png"
    

    It's a little shorter, and it works for me.

  • Switch between outputs, digital and analog input

    Forgive me, I'm sure that there is a simple answer to my problem, but being relatively new to LabView, I do not know how to proceed.

    With the help of producer/consumer achitecture I am trying to accomplish the following:

    Producer

    1. Relay nearby
    2. Read the voltage

    Consumer

    1. Compare the voltage to the expected value and append the true/false value in a table.

    It will be run 8 times then wait for input from the user through the dialog box run then 8 times.

    My question/problem is how I set up so that the digital analog in and out are timed correctly and get a sample of AI after each relay is closed?

    Material used is the cDAQ, (2) NI9481 & NI9221 (1)

    Attached, is the vi that I came with this day and a diagram to illustrate the intended application.

    Any help is greatly appreciated.


  • ListView and ListItem displaying funny

    How is it when I have my. XML directly in my ListView, all list items display correctly, but if I add data to a data source, it is not.

    Example below because I can't explain it very well.

    ListView {
                dataModel: XmlDataModel {
                    source: "hills.xml"
                }
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData.key
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    

    Vs.

    ListView {
                dataModel: dataModel
                listItemComponents: [
                    ListItemComponent {
                        type: "listItem"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
                    ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData.key
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    
    ...
    
    attachedObjects: [
            GroupDataModel {
                id: dataModel
                sortingKeys: [
                    "skiHill"
                ]
            },
            DataSource {
                id: dataSource
                source: "hills.xml"
                query: "/root/listItem"
                onDataLoaded: {
                    dataModel.insertList(data);
                }
            }
    

    On the 2nd day of two different types of lists, the list item displays the news from another part of my XML, not the name of ski hill.

    Your head should look like:

     ListItemComponent {
                        type: "header"
                        Header {
                            title: ListItemData
                            touchPropagationMode: TouchPropagationMode.None
                        }
                    }
    

    i.e. just use ListItemData for the title - because since a GroupDataModel (and probably XmlDataModel) the first level of the row is always returned as a string, not as a piece of real data that has properties

    ListItemComponent {
                        type: "item"
                        StandardListItem {
                            title: ListItemData.skiHill
                        }
                    },
    

    Your list items must have the type 'point' - because that's what indicates the GroupDataModel.

    You can substitute by using a reminder in QML itemType(), if you need something different, or if you need a mixture of different types in the list

  • How to dynamically change an element in the GroupDataModel?

    I have the controllor custom as the checkbox on each row of a listview. When I check or uncheck the check box, I need to update the data with the row in GroupDataModel. I tried to change the property directly in the ListItemData, but it cannot be changed. I think I should browse the GroupDataModel and find that data, and then update it. Does anyone know how to realize this way cascading only? Thank you.

    I understood how to retrieve the group header element and child elements. I can also update any element children in the GroupDataModel.  If you have a better solution, please let me know. Thank you

    Please see my source code.

    for(var i=0; i < xxxDataModel.size(); i++ ){
        var indexPath = new Array();
        indexPath[0] = i;
        var headerItem = xxxDataModel.data(indexPath);
        if (headerItem != null){
            var childCount = xxxDataModel.childCount(indexPath);
            for (var j=0; j		   
  • ListView and point unselectable

    I would like to make sure items are not selectable by the user.

    In particular, I have to use a ListView with GroupDataModel and waterfalls create virtual component to a group.

    There is a problem with the multiple selection function or selectall.

    Nicolas

    Thank you very much, I'll use your workaround. So finally,.

    -in the ListView component:

    onSelectionChanged: {
      if (indexPath.lenght == 1)
        select(indexPath, false); // Don't allow selection
    }
    

    -in the ListItemComponent:

    ListItem.onSelectionChanged: {
      if (ListItem.indexPath.length == 1)
        ListItem.view.select(ListItem.indexPath, false);
    }
    

    Nicolas

  • Disable sorting in GroupDataModel

    Hello

    My application insert QVariantMap to a GroupDataModel and it happens on a random time.

    When the GroupDataModel has a StandardListItem, it automatically sorts its elements (in alphabetical order)

    Is it possible to turn off sorting?

    Thank you!

    Hello
    Perhaps ArrayDataModel would fit better - he's not sort items.

  • Error: unknown type: object is not an array.

    Hello

    I am manually completing a portion of my dataModel, if I put it in a table then it does not display anything, but if I put it to an object then it displays correctly and it compiles without error, but in momentics I get the following error message appear:

    "A type error: unknown type: object is not an array."

    is there a way to get around this...

    .....

    //var dataLine=new Array();
    var dataLine = new Object();
    dataLine["Title"] = "My Title";
    dataLine["Description"] = "My Description";
    myDataModel.append([dataLine]);
    

    Hello

    My dataModel is a GroupDataModel and the code is all in QML/javascript where I'm populating the GroupDataModel so I don't know how I acceding QList QMap ect.

    After some research I found an example like this: that seems to work

    searchDataModel.append({
                            "Title": "MyTitle",
                            "Description": "Rome"
                           });
    
  • Folder file list order

    Hello

    New to LabView. I created a VI that reads and analyzes (RMS and power medium frequency) files in a .txt file, and then adds the data in a simple text file. I noticed, though, that when I remove my for loop and reading and writing files individually, I get different values in my program "reading in bulk. I want to make two things 1) be able to strip the first 20 characters of the name of the file and add these characters in the attached file or 2) know how to change the order in which the .txt files are read and appended. I'm analyzing muscle contractions, so the order is vitally important. I enclose my VI. Thank you in advance.

    You may be bitten by the fact that alphabetical order does not always mean numeric order. If your files are text1.txt, text2.txt, etc., the alphabetical list is text1.txt, text10.txt, text11.txt, text2.txt, text20.txt.

    Some workaround solutions, if that's the case, but my first suggestion would be to rename the existing files and numbers are used in all future measures the pad.  Text01.txt or text001.txt depending on the number of files.

  • Report Word formatting problems

    Hello

    I have two problems with the format of Word document automatically created in LabVIEW using the palette of report generation (specific Word).

    1.
    There are added additional lines between each section made by Easy Text.vi Word.

    2.
    I want to insert a table without border lines. However when I set borders and shading in a way this table without any boundaries should generated vertical border remain lines between the columns of the table.

    Any help will be greatly appreciated.

    Best regards.

    Martin

    mavlc wrote:

    Hello

    I have two problems with the format of Word document automatically created in LabVIEW using the palette of report generation (specific Word).

    1.
    There are added additional lines between each section made by Easy Text.vi Word.

    2.
    I want to insert a table without border lines. However when I set borders and shading in a way this table without any boundaries should generated vertical border remain lines between the columns of the table.

    Any help will be greatly appreciated.

    Best regards.

    Martin

    2. I want to insert a table without border lines. However when I set borders and shading in a way this table without any boundaries should generated vertical border remain lines between the columns of the table.

    Set the entry AutoFormat in Word Input.vi easy to 0 will create a table without the internal lines, but that doesn't solve your problem #1.

    1. There are added additional lines between each section made by Easy Text.vi Word.

    These additional lines are added by the easy text and the easy Table.vi Word. If you don't want them using these screws. use the report text Append and Append table of the report live as in the following photo. (you then need to set the style using Word Format Text.vi as I did for the title).

    Ben64

  • Adding handwriting on a spreadsheet file

    Same problem as this guy here:http://forums.ni.com/t5/LabVIEW/write-to-excel-spreadsheet-in-columns-and-append-to-file-in-a/m-p/10...

    I'm in labview 7.1.  I am reading data and want to add on the new columns, while the excel spreadsheet function simply adds it on the bottom of the file.

    Y at - it an easier way to do it, or should I write a VI that reads from a file of the current worksheet, and then adds the data in the table, as said in this link?

    Thank you

    If you want to add columns, you will need to read in the data spreadsheet and use insert into to add to the columns Array.  Simply specify column instead of the line index indexes.  Or you could transpose the table insert in Array by using the row index and then convert again.  Then write all back.

  • ListView will not display datamodel set of c ++

    I have a listview that retrieves a file from a web service json and it analyzes in a datamodel (tried GroupDataModel and QListDataModel). Thanks to some discussions that I found here, I managed to get the data in the data model and attach properly to the listview. which I checked through debugging.

    However; When I return to QML, I'm not able to get the data to display.

    My loots listview like that at the moment, but it's really just a lighter version of what I want, since I'm trying to make it work:

    ListView {
                                objectName: "list"
                                listItemComponents: [
                                    ListItemComponent {
                                        type: "item"
                                        Container {
                                            id: root
                                            WebImageView {
                                                url: ListItemData.image
                                            }
                                            Label {
                                                text: ListItemData.title
                                            }
                                        }
                                    }
                                ]
                            }
    

    Regarding my code, c ++, I use the Twitter example found here as my base:

    http://supportforums.BlackBerry.com/T5/Cascades-development/method-for-making-an-HTTP-style-request-...

    For reference, if I try to use QListDataModel, my cards will eventually look like this:

     QMap(("Description", QVariant(QString, "Description here") ) ( "image" ,  QVariant(QString, "https://image.com/image.jpg") ) ( "title" ,  QVariant(QString, "title") ) )
    

    As I said, I see the datamodel get associated with my list by list-> setDataModel (model); but it does not display anything. I'm sure it's something on the side QML that I'm hurting, but hopefully someone here can help.

    So, I realized my problem while working on another part of the application.

    Unlike the example of Twitter I've provided, I wasn't using a global variable for * root. I believe that when I started with this example, that part was giving me problems, so I used local variables. For this reason, my application created the root object in the initialization and the method of "GetTimeline".

    Once I did fixed it is global, the list filled.

    Thanks for your help on this everyone.

  • QVariantMap loss of pointers

    I'm passing pointers for instance in one of my classes around as an element of a QVariantMap. 98% of the time it works well, while 2% is killing me. Sometimes when I extracted the pointer elsewhere in my app it comes out as NULL rather than this pointer valid that was on there.

    Here's an example of how to get the pointer in the QVariantMap:

    MyClass* myClassPtr;
    QVariantMap map;
    
    myClassPtr = &myClassInstance;
    map["title"] = "Pointer to my class";Q_ASSERT(myClassPtr);
    map["myClass"] = QVariant::fromValue( myClassPtr );Q_ASSERT(map["settings"].value());
    

    Once the 'map' is filled with other values too happening around in the application by various means, such as a signal when the user does something. In contrast, when I need the pointer back, I do the following:

    MyClass* myClassPtr = map["settings"].value();Q_ASSERT(myClassPtr);
    

    As I said, 98% of the time this works as expected, but the remaining time the pointer spell back as NULL, which obviously has critical implications when I try to call functions of the object of it. Strangely, the "title" element always comes out correctly even when the pointer is not. I know that the pointer is lost in transit because the first and the second fire Q_ASSERTs never, even when the third. Either way, I am trying to retrieve the pointer to the same place in the code every time. It will work fine 10, 20, 40 times in a row, then next time... boom!

    I can not understand what is happening here.

    Update: on the off-chance that it might be useful, I'll explain how the QVariantMap happening around. Only the first block of code is a class that generates a QList and use it to fill a GroupDataModel.

    The second block is a function that is triggered when the user clicks on one of the items in the ListView that uses this GroupDataModel, and it gets the path of the index of the item that the user has typed as a parameter. To develop this second block:

    QVariantMap map = dataModel->data( indexPath ).value();
    QString title = map["title"].toString();
    myClass* myClassPtr = map["settings"].value();
    Q_ASSERT(myClassPtr);
    

    AsI said before "title" comes out correctly, and usually 'settings', but not always. Maybe someone notices something wrong with this additional detail.

    UPDATE: Turns out that I was running a red herring, because it has nothing to do with QVariantMap. After weeks of having my app "randomly" close last night, I realized that there was a reason after all and I learned something new about ListView.

    What I didn't know, is that numbers of ListView by triggered() report not ONLY when you tap an item in the list, but also when you tap on a header. My articles are quite large while my headers are very narrow. What was going on, it was that a few times out of a hundred, I got a little sloppy typing element and hit header instead. This triggered a function which should receive a path index pointing to a QVariantMap of the datamodel that had been filled with the item "settings". When I typed in the header error, it was not to do the QVariantMap with the 'settings' so when I cast to MyClass * liquidation was always NULL.

    What made it particularly difficult to identify, it is that I'm very rarely enough botched hit header by mistake, and there was no indication that I had done, so I thought the app was going to die when I was the ListView element you tapoterez normally. I didn't know that ListView sends a signal triggered() for valves header too.

    I fixed it by checking the length of row in the slot in onTriggered of the ListView. If the length is two then an item has been exploited, so I call the function. However, if the length is one then this is a header instead, so I did nothing.

Maybe you are looking for

  • Re: P750-13N wrong display driver

    Hello I just bought a Toshiba Satellite P750-13N. When I got the laptop, I put my recovery disk disk and down them. I have my setup of the laptop and the loan, but I noticed that I have view the drivers installed. The Nvidia driver and Intel HD famil

  • Cannot read on satellite L30 - 10W

    I can't play witch game Emergency 4... My problem: [DxDiag | http://doskonaly67.republika.pl/textowe/log/dxdiag.txt] [Emergency 4 - logfile | http://doskonaly67.republika.pl/textowe/log/logfile.txt] [Catalyst-log | http://doskonaly67.republika.pl/tex

  • HP 300-030na: you can add a ssd to the HP 300-030na

    Hello I want to know is you can add a ssd M2 to the HP 300-030na as a second hard drive? I would like to have the essential motivation of the ssd for the speed of startup and disk of 1 TB for storage. Is - this somthink is that you can do on this mac

  • can I use my webcam on my new macbook pro to talk on messenger to my friends

    Webcam/macbookpro/Messenger Can I tun on my webcam... .to starting from my new macbook pro, so I can talk on messenger to my friends, how can I do that, can someone help me to do this.

  • Offline - unavailable for reconnect domain files.

    Hello I have a problem for a user where he records seeing the 'work offline' message in the system tray, he got a network IP address, can have access to most network resources but no network drive. By clicking the offline files icon, it says "domian