[ 12 posts ] Go to page 1, 2 Next

Priyanka Komakula

  • Username: pkomakula
  • Joined: Thu Jun 07, 2012 11:34 am
  • Posts: 8
  • GitHub: pkomakula
  • Gists: pkomakula
  • IRC: pkomakula
  • Offline
  • Profile

YUI Widget Datatable cell edit

Post Posted: Thu Jun 07, 2012 11:48 am
+0-
Hi,

I have a Datatable with 3 editable columns A, B, and C (A + B). When the value of column A or B is changed, C should be updated with the corresponding A+ B value. I tried using the onEventEditCell but the event is not triggered when I edit a cell. Can anyone help me with this please?

Thanks in advance!

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Thu Jun 07, 2012 12:35 pm
+0-
The onEventXxxx methods are not events that get triggered but methods that you may call so DataTable can respond to some event you determine. They are ready-made event listeners that you can hook to events, not events. They are listed under methods, not under events.

What you are looking for is editorSaveEvent. The first argument gives you lots of information. Check the BaseCellEditor class. Use any of the several getXxxx methods to find out the column, the Record instance and whatever you might need to figure out what got edited.

Priyanka Komakula

  • Username: pkomakula
  • Joined: Thu Jun 07, 2012 11:34 am
  • Posts: 8
  • GitHub: pkomakula
  • Gists: pkomakula
  • IRC: pkomakula
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Mon Jun 11, 2012 1:09 pm
+0-
Thank You for the response Satyam. It helped.

I have one more question....I am trying to implement the Save functionality to Save the changes made to cells to backend database. I want to put a Save & Cancel buttons in a separate column for each row so that the whole row can be saved at a time to the backend instead of each cell. I want to Save all the column values in a particular selected row to the backend when Save button is clicked. And I want to revert back the editted column values to old values when Cancel button is clicked. How can I achieve this functionality?

Thanks in advance.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Mon Jun 11, 2012 11:33 pm
+0-
There is nothing specific in DataTable to help you on that. You will have to manage the storage of the previous values somewhere else so that you might eventually restore them to the Record.

Actually, you can store in the Record itself whatever you want beyond the fields you show. You can add the previous values of any field as a separate field in the Record itself (setData allows you to add new values just by giving it a new key name).

Do not attach events to the buttons themselves, use DataTable cellClickEvent to listen to any cell click and then figure out if it was a button and which one.

Priyanka Komakula

  • Username: pkomakula
  • Joined: Thu Jun 07, 2012 11:34 am
  • Posts: 8
  • GitHub: pkomakula
  • Gists: pkomakula
  • IRC: pkomakula
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Tue Jun 12, 2012 9:55 am
+0-
Hi Satyam,

Thanks for your response.....

{ key: "Actions", width: 200, resizeable: true, formatter: function (cell, rec, col, data) { cell.innerHTML = '<button class="MowButton MowBtnSize18-80" id="buttonSave" name="buttonSave" type="submit" value="Save" > Save </button> <button class="MowButton MowBtnSize18-80" id="buttonCancel" name="buttonCancel" type="button" value="Cancel"> Cancel </button>'; } }

I have added a column with 2 buttons Save and Cancel in the datatable as above. In CellClickEvent, I am able to find out which column is clicked, but how do I find out which button has been clicked?

Thanks.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Tue Jun 12, 2012 10:40 am
+0-
The easiest is to make a separate column for each button. In that way, you don't even really need to put buttons there, you can use the className that DataTable assigns to each column to format the cell so that it looks like a button without it really being one.

Priyanka Komakula

  • Username: pkomakula
  • Joined: Thu Jun 07, 2012 11:34 am
  • Posts: 8
  • GitHub: pkomakula
  • Gists: pkomakula
  • IRC: pkomakula
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Tue Jun 12, 2012 11:58 am
+0-
Hi Satyam,

{ key: "Amount", label: "Credit Amount", editor: new YAHOO.widget.TextboxCellEditor({ disableBtns: true}), sortable: true, width: 200, resizeable: true, formatter: "currency" },
{ key: "AmountDup", width: 200, resizeable: true, formatter: function (cell, rec, col, data) { var amt = rec.getData("Amount"); cell.innerHTML = amt; }

I have 2 columns Amount and AmountDup in a datatable. The AMount & AmountDup column values are populating correctly on the Datatable on UI.But in CellClickEvent, when I am trying to get the data of AmountDup column....its returning Undefined. Why so? How can I get the data in AmountDup column?

myDataTable.subscribe("cellClickEvent", function (oArgs) {
var elRow = oArgs.target;
var oRecord = this.getRecord(elRow);
var amnt = oRecord.getData("Amount");
var amntDup= oRecord.getData("AmountDup");

Here the column Amount value is returned correctly but AmountDup column value is returned as "Undefined". Can you please help me with this?

Thanks.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Tue Jun 12, 2012 9:24 pm
+0-
Because there is no such field in the Record. You are placing a copy of Amount into an extra column in the HTML the user will see, but not in the Record.

The fields you mention in the DataSource are the ones that go into the Record, those that you list in the columns definition might correspond or not to those in the DataSource. If they match, their values as stored in the Record will be shown, if there are more, as in AmountDup, you have to make it up, but that is just for display purposes, the Record remain the same.

To have a value in the Record either you have to list it in the DataSource or you set it with setData. Showing something in an extra column does not store it in the Record, it just shows it.

Priyanka Komakula

  • Username: pkomakula
  • Joined: Thu Jun 07, 2012 11:34 am
  • Posts: 8
  • GitHub: pkomakula
  • Gists: pkomakula
  • IRC: pkomakula
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Mon Jun 25, 2012 10:48 am
+0-
Hi Satyam,

I want my yui Datatable cell editor to accept only integer numbers (no decimal numbers). How do I do that? Could you please help me with this?

Thanks in advance.

Satyam

YUI Contributor

  • Username: Satyam
  • Joined: Tue Dec 09, 2008 12:34 am
  • Posts: 2016
  • Location: Sitges, Spain
  • GitHub: Satyam
  • Gists: Satyam
  • IRC: DevaSatyam
  • YUI Developer
  • Offline
  • Profile

Re: YUI Widget Datatable cell edit

Post Posted: Mon Jun 25, 2012 12:34 pm
+0-
See validator:

http://developer.yahoo.com/yui/docs/YAH ... _validator

return undefined to reject entry.
  [ 12 posts ] Go to page 1, 2 Next
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
cron