Results 1 to 3 of 3

Thread: Form items list

  1. #1
    Sencha User
    Join Date
    Jul 2007
    Posts
    7

    Thumbs up Form items list

    I have a grid that has a toolbar at the top. The toolbar allows the user to add a new item (road association) to the grid, as well as edit an existing one. To add or edit the item, I use a window that has a form panel as its item. See the attached picture.

    Everything works great except a scenario where the page is loaded, a row is selected, and the user clicks on the Add toolbar button. When this occurs, the form fields are not empty since they were set when the grid row select event was fired. If the window is closed and the Add button is clicked again, the form is empty (as expected).

    I suspect that the issue is due to lazy rendering. Let me explain ...

    When a row is clicked in the grid, the form fields are set from the data in the row selected. One thing to note is that this code can occur before the window (and form) are actually displayed.

    Code:
    theForm.findById('name').setValue(row.Name);
    // ... do this for the rest of the form fields
    Now, when the Add button is clicked, the form must show with its fields empty, so the code in the corresponding handler looks like this:

    Code:
    handler: function() {
        alert(editForm.form.items.length);
        Ext.each(editForm.form.items.items, function (formItem, index, allItems) {
            formItem.setValue(null);
        });
        win.show('tbAdd');
    }
    In the scenario I mentioned above, the form items length array is 0. When the Add button is re-clicked, the array length is 6 (the number of fields on the form).

    Any suggestions on how to solve this?
    Attached Images Attached Images

  2. #2
    Sencha User hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,966

    Question

    @yuiman -- Have you tried:

    Code:
    handler: function() {
    //    alert(editForm.form.items.length);
        editForm.getForm().reset();
        win.show('tbAdd');
    }
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


  3. #3
    Sencha User
    Join Date
    Jul 2007
    Posts
    7

    Default

    I plugged that code in and got the same result. Very mysterious glitch ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •