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

YUI DataTable and formatter: button

Expand Messages
  • levisenft
    I ve created a DataTable with buttons in one column using the following column define syntax: {key: delete , label: , sortable:false,
    Message 1 of 2 , Oct 9, 2007
    • 0 Attachment
      I've created a DataTable with buttons in one column using the
      following column define syntax:

      {key:"delete", label: "", sortable:false, resizeable:false,formatter:
      "button"}

      How can I change the text of each button? They all have default value
      "click", how can I change the value?

      Thank you,

      Levi
    • Satyam
      The button formatter will make a button with the label taken from the data in the field. If it is an added column with no underlying data, it will put the
      Message 2 of 2 , Oct 9, 2007
      • 0 Attachment
        The button formatter will make a button with the label taken from the data
        in the field. If it is an added column with no underlying data, it will put
        the text "Click" on it.

        You can easily change that by defining your own on-the-spot formatter:

        {key:"delete", label: "", sortable:false, resizeable:false,formatter:
        function (elCell) {
        elCell.innerHTML = '<button>Delete</button>';
        }}

        The formatter function receives additional arguments, which you can see in
        the documentation but I think you might not be concerned with. Just as you
        can draw a button, you might as well draw an image or whate4ver you want by
        setting the innerHTML of the container cell. For a button you would have to
        listen to buttonClickEvent, for clicks on images to cellClickEvent and if
        you insert a hyperlinklink to linkClickEvent.

        In http://yuiblog.com/blog/2007/09/26/satyam-datatable-2/, the first section
        of the article deals with drawing an icon and then responding to it in order
        to delete a record.

        Satyam



        ----- Original Message -----
        From: "levisenft" <levi@...>
        To: <ydn-javascript@yahoogroups.com>
        Sent: Tuesday, October 09, 2007 5:40 PM
        Subject: [ydn-javascript] YUI DataTable and formatter: button


        > I've created a DataTable with buttons in one column using the
        > following column define syntax:
        >
        > {key:"delete", label: "", sortable:false, resizeable:false,formatter:
        > "button"}
        >
        > How can I change the text of each button? They all have default value
        > "click", how can I change the value?
        >
        > Thank you,
        >
        > Levi
        >
        >
        >
        >
        > Yahoo! Groups Links
        >
        >
        >
        >
        >
        > --
        > No virus found in this incoming message.
        > Checked by AVG Free Edition.
        > Version: 7.5.488 / Virus Database: 269.14.5/1058 - Release Date:
        > 08/10/2007 16:54
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.