Welcome, Guest
  • Author Topic: Combobox problem (probably obvious answer)  (Read 1809 times)

    cjhsb

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Combobox problem (probably obvious answer)
    « on: 08/04/05, 10:53 »
    Hi all,

    Firstly let me excuse myself by saying I'm pretty new to Flash.

    I've read a number of posts on this and other boards regarding problems with comboboxes and managed to work my Actionscript around into something that I feel should be working as a result.  However, I can't find the specific answer to my quandry, and I'm tearing my hair out trying to fix it on my own! ???

    The idea is pretty simple - populate a Combobox with one column from a Dataset.

    Here's my script so far:

    trace(TentTypesDataSet.schema);
    var lo:Object = {};
    lo.afterLoaded = function(){
    trace ("Lo function triggered (dataset loaded)");
       count = TentTypesDataSet.length;
    trace ("RS function triggered");
    trace(count);
       for(i=0;i<count;i++)
       {
    TentTypesCB.addItem(TentTypesDataSet.NAME.getItemAt(i),TentTypesDataSet.NAME.getItemAt(i));
    trace (i);
    trace (TentTypesDataSet.NAME.getItemAt(i));
       }
    }
    TentTypesDataSet.addEventListener("afterLoaded", lo);



    The debug output from this reads as follows:

    <properties><property name="ID"><type name="Integer" original="false"><validation className="mx.data.types.Int"><settings /></validation></type></property><property name="NAME"><type name="String" original="false"><validation className="mx.data.types.Str"><settings /></validation></type></property><property name="SIZE"><type name="String" original="false"><validation className="mx.data.types.Str"><settings /></validation></type></property><property name="INFO"><type name="String" original="false"><validation className="mx.data.types.Str"><settings /></validation></type></property><property name="PRICE"><type name="String" original="false"><validation className="mx.data.types.Str"><settings /></validation></type></property><property name="IMAGE"><type name="String" original="false"><validation className="mx.data.types.Str"><settings /></validation></type></property></properties>
    Lo function triggered (dataset loaded)
    RS function triggered
    4
    0
    undefined
    1
    undefined
    2
    undefined
    3
    undefined


    It seems obvious to me that I'm not calling the values stored in the column called NAME correctly, as everything else appears to work.

    Can anyone out there please tell me how to correctly call the data held in NAME, as TentTypesDataSet.NAME.getItemAt(i) doesn't work nor do any of the logical alternatives I have tried.

    Many thanks in advance (and for my hair too!)

    Carl
    « Last Edit: 08/04/05, 11:50 by cjhsb »

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #1 on: 08/04/05, 11:52 »
    Should be:

     TentTypesDataSet.getItemAt(i).NAME

    Where NAME is the name of the column

    Jorge

    cjhsb

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #2 on: 08/04/05, 12:34 »
    Should be:

     TentTypesDataSet.getItemAt(i).NAME

    Where NAME is the name of the column

    Jorge

    Thanks for the quick reply Jorge, it's much appreciated.

    I thought when I read that somehow I had missed trying it that way round, but no, that still gives me the same output of 4 lots of undefineds.  :(

    Any other ideas?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #3 on: 08/04/05, 12:59 »
    Inspect your row:

    trace (i);
    row = TentTypesDataSet.etItemAt(i);
    for(z in row) trace(z+":"+row[z])

    Jorge

    cjhsb

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #4 on: 08/04/05, 13:42 »
    Inspect your row:

    trace (i);
    row = TentTypesDataSet.etItemAt(i);
    for(z in row) trace(z+":"+row[z])

    Jorge

    Ok, that added like so:

    trace(TentTypesDataSet.schema);
    var lo:Object = {};
    lo.afterLoaded = function(){
    trace ("Lo function triggered (dataset loaded)");
       count = TentTypesDataSet.length;
    trace ("RS function triggered");
    trace(count);
       for(i=0;i<count;i++)
       {
    TentTypesCB.addItem(TentTypesDataSet.getItemAt(i).NAME,TentTypesDataSet.getItemAt(i).NAME);
    trace (i);
    row = TentTypesDataSet.getItemAt(i);
    for(z in row) trace(z+":"+row[z]);
    trace (TentTypesDataSet.getItemAt(i).NAME);
       }
    }
    TentTypesDataSet.addEventListener("afterLoaded", lo);

    Adds nothing to the output window:

    Lo function triggered (dataset loaded)
    RS function triggered
    4
    0
    undefined
    1
    undefined
    2
    undefined
    3
    undefined

    Hope that helps?

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #5 on: 08/04/05, 13:52 »
    Sorry, thinking in a datagrid not in a dataset. Check docs, getItemAt is a method of datagrid. Use mydataset.next() and myDataset.currentItem.NAME to get values. Example code on Flash manual.

    Jorge

    cjhsb

    • Server what's that
    • *
    • Posts: 4
      • View Profile
    Re: Combobox problem (probably obvious answer)
    « Reply #6 on: 08/04/05, 16:26 »
    Sorry, thinking in a datagrid not in a dataset. Check docs, getItemAt is a method of datagrid. Use mydataset.next() and myDataset.currentItem.NAME to get values. Example code on Flash manual.

    Jorge

    Ah yes that would indeed do it - no need to apologise - it was my mistake to start with!

    Works great now, thanks again Jorge! ;D