Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] DataTable: ID's to cellwidgets?

Expand Messages
  • Satyam
    It is better if the DataSource deals only with data, not with the user interface. You can add extra column to a DataTable in the column definitions array.
    Message 1 of 4 , Aug 3 12:14 AM
    • 0 Attachment
      It is better if the DataSource deals only with data, not with the user
      interface. You can add extra column to a DataTable in the column
      definitions array. Not all columns need to be associated with an
      existing data field nor do all fields need to be shown. It is there, in
      the column definitions, where you add widgets to the column by defining
      your own formatter for that particular column.

      You don't bother assigning Ids to particular controls in DataTable
      cells. Usually your data will have a primary key for each record. this
      primary key may or may not be shown, usually it won't, but it is
      nevertheless accessible in the Record object for that row. You don't
      place event listeners for each cell either, the DataTable provides
      events cellClickEvent, buttonClickEvent and so on that allows you to
      detect user interaction. It is very easy to listen to any of them, from
      the cell clicked pick the column and record, and from the record, the
      primary key and all field values for the record, and then decide what
      you do to it.

      myDataTable.on('cellClickEvent', function (oArgs) {
      var targetEl = oArgs.target;
      var oRecord = this.getRecord(targetEl);
      var primaryKey = oRecord.getData('primarykey');
      var oColumn = this.getColumn(targetEl);
      switch (oColumn.key) {
      // here, from the column key, you decide what to do with that
      click, if anything.

      });

      Satyam


      Nikias escribió:
      > Hi,
      >
      > I'm exploring the DataTable a bit.
      > Not knowing every detail from the DataTable yet, I know what I expect it should do for my application. So before beginning a trial and error journey, i rather ask here first if it's possible to create(/modify) a datatable that can contain widgets in its cells that have an id.
      > Seeing the output of a datatable give me the idea it's possible, but the examples i've seen so far, the data of the DataSource look simple as KEY-VALUE.
      > While i for instance would want
      > KEY-{Button:{label:"click", id:"Btn_xyz", onclick: "dothis()"}},
      > KEY-{Input:{prompt:"type here", id:"inp_xyz", onchange: "updateServer()"}}
      > (button and input are in different columns, as in the examples)
      >
      > I know formatterWidgets exist for the dataTable, but i want to give them a unique identity with each there own properties.
      >
      > After this would be created I could interact with the widgets without passing through the DataTable.colX.rowY to change some property of it.
      >
      > Anyone that could tell me if that would be possible?
      >
      > Kind regards.
      >
      >
      >
      >
      > ------------------------------------
      >
      > Yahoo! Groups Links
      >
      >
      >
      > ------------------------------------------------------------------------
      >
      >
      > No virus found in this incoming message.
      > Checked by AVG - www.avg.com
      > Version: 8.5.392 / Virus Database: 270.13.42/2278 - Release Date: 08/02/09 17:56:00
      >
      >
    • Nikias
      The approach which i was wondering about, would give me direct access to the widget in the table. I would not have to pass the DataTable Object for a
      Message 2 of 4 , Aug 3 4:17 AM
      • 0 Attachment
        The approach which i was wondering about, would give me direct access to the widget in the table. I would not have to pass the DataTable Object for a property-update coming from the server for that widget. It could seem unlogic for wanting to update a cell's content(here a widget object) one time directly and the next time through the datasource. But if the datasource works only one way, there is nothing standing in this mixed-approach's way, i guess.

        But for the moment, i'll stick with your articles-way(via the DataSource) for updating the widgets in my table.
        (I didn't read part2 yet)

        Thanks for the response.
      • Satyam
        The original data for the DataTable lies on the Recordset, not in the document body. It is best to avoid accessing the UI bypassing the widget that is in
        Message 3 of 4 , Aug 3 10:26 AM
        • 0 Attachment
          The original data for the DataTable lies on the Recordset, not in the
          document body. It is best to avoid accessing the UI bypassing the
          widget that is in charge. If you keep the RecordSet updated, the
          DataTable will take care to do the screen part.

          BTW, this might help you:

          http://www.satyam.com.ar/yui/2.6.0/assortedControls.html

          Satyam

          Nikias escribió:
          > The approach which i was wondering about, would give me direct access to the widget in the table. I would not have to pass the DataTable Object for a property-update coming from the server for that widget. It could seem unlogic for wanting to update a cell's content(here a widget object) one time directly and the next time through the datasource. But if the datasource works only one way, there is nothing standing in this mixed-approach's way, i guess.
          >
          > But for the moment, i'll stick with your articles-way(via the DataSource) for updating the widgets in my table.
          > (I didn't read part2 yet)
          >
          > Thanks for the response.
          >
          >
          >
          > ------------------------------------
          >
          > Yahoo! Groups Links
          >
          >
          >
          > ------------------------------------------------------------------------
          >
          >
          > No virus found in this incoming message.
          > Checked by AVG - www.avg.com
          > Version: 8.5.392 / Virus Database: 270.13.42/2278 - Release Date: 08/02/09 17:56:00
          >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.