7 Replies Latest reply on Oct 2, 2008 11:56 AM by ntsiii

    Updating the dataprovider of a datagrid

    flex2008 Level 3
      I have a datagrid with an arraycollection as the dataprovider.In one of the columns there is a combobox used as the itemeditor.I want the user to select values from the combobox and when a submit button is clicked the datagrid dataprovider needs to be updated.
      Once the submit is pressed,he should not be able to change the values using any of the comboboxes where he has already selected some values.

        • 1. Re: Updating the dataprovider of a datagrid
          ANewFlexUser Level 1
          Do you want the items to remain un-editable only for the duration of this session, or whenever the same user logs back on to that screen?

          For a session-only duration, I can picture this being handled by a pair of booleans on the objects in question, both false by default. When he edits the datagrid item, set a holder boolean to 'true'. When he clicks the 'submit' button, loop through the array collection, and wherever you have a holder boolean set to 'true', set the second boolean, the permanent boolean, to 'false'.

          I have attached the examples of what I'm talking about.
          • 2. Re: Updating the dataprovider of a datagrid
            nikos101 Level 2
            What is the arrayProvider, the dataProvider of the grid?
            • 3. Re: Updating the dataprovider of a datagrid
              nikos101 Level 2
              Sorry I think the arrayProvider is the dataProvider of the grid
              • 4. Re: Updating the dataprovider of a datagrid
                ANewFlexUser Level 1
                Yes, it is. Sorry that's a bit confusing, I didn't really specify.

                Also, in looking at my editorHandler function, it needs some changes. Right now it will prevent editing of an entire row when the corresponding boolean is set. In order to prevent editing of just the one cell, it should look more like this:
                • 5. Updating the dataprovider of a datagrid
                  flex2008 Level 3
                  What I want is once the submit button is pressed,the changes will be made in the database.So after that the user cannot change the values for those particular rows.Only for the rest of the rows can the user choose a value using combobox...
                  • 6. Re: Updating the dataprovider of a datagrid
                    ANewFlexUser Level 1
                    The only way I can see to do that would be to have the database default to null values in all the columns, and then check for that with your edit handler. We use managed collections at work, which means a second collection would be required; one to store the temporarily selected values, the other to stay connected to the data in the dataBase. Edit the temporary collection, and then when the Submit button is clicked, copy the temporary collection over to the one linked collection. Maybe one of the more experienced users on here has another solution? I don't know.

                    This is the kind of event handler I am talking about, BTW:
                    • 7. Re: Updating the dataprovider of a datagrid
                      ntsiii Level 3
                      null or empty string or zero of some other known value.

                      But first be sure your itemrenderer is working correctly.

                      You ComboBox renderer must be updating the dataProvider item when the user interacts with it.

                      Then, I might use the renderer to determine whether a use can interact with a cell. If the value has the empty or null or whateve value then the rendere shows the combo box, otherwise it shows a label.

                      Tracy