Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba


Go to End

29 Posts   33751 Views


Community Member, 33 Posts

7 January 2012 at 12:25am

Edited: 07/01/2012 1:44am

OK. That works indeed.
You guys are great !
But still remains this one issue that's keeping me hostaged from the beginning :

in the screenshot, you'll see that the showdata() function in the controller is not found.


Community Member, 288 Posts

7 January 2012 at 2:11am

Ok looking at the last image it's sending a POST request to http://localhost/DGFmn/JTableExample/showdata/ and from what I can see of your address bar that URL should be http://localhost/DGFmn/new-jtableexample/showdata/ but I'm not seeing the whole address bar so I might have gotten that a bit wrong. Change your listAction url to match what's in the address bar if I got it wrong with the addition of showdata/.

Also sending back stuff like "<script type='text/javascript'>alert('In showdata function');</script>"; will never work since the script is expecting a JSON response. All you're doing is breaking the JSON. In order for something like that to be executed it would actually have to be appended to the DOM tree and that's never going to happen in a JSON context.


Community Member, 33 Posts

7 January 2012 at 2:28am

And bingo !
Thx alot.
There are some minor error concering css and things, but the JTable loads shows.
Going to work tomorrow on the insert/update/delete, but after a good nap...

Attached Files

Community Member, 33 Posts

7 January 2012 at 7:06pm

Edited: 07/01/2012 7:58pm

Still in the context of JTable in Silverstripe.
Is there a way to get the rowID of the last inserted row ?
I collect data, create a new dataobject, assign the data to the properties and write() so that
sapphire does takes care of the SQL handling. Now I just want to get back the ID (which is an
autoincrement in the SQL table) of this last inserted row.
You cannot say:
DataObject::get('People') which gives you a resultset and then select the LAST item of this resultset.
This gives you the last record in the database, not the latest inserted record ...

It's possible in SQL, but if there is a way in Sapphire ?


Community Member, 288 Posts

8 January 2012 at 3:19am

After you've done a write() that dataobject will have an ID and if that write() was an INSERT that ID will be the last rowID. $dataobject->ID to access.


Forum Moderator, 1391 Posts

8 January 2012 at 7:49am

AFAIK the write function even returns the ID, so you should be able to

$ID = $myObject->write();
if (!empty($ID)) ...


Community Member, 288 Posts

8 January 2012 at 9:17am

Yes martimiz is indeed correct, write() does return the ID so it's there for you to grab directly from the function.


Community Member, 33 Posts

10 January 2012 at 6:24am

Edited: 10/01/2012 6:26am

Thank you. It worked indeed. But since then, I really have a hard problem in this project. In the controller, I had to include some javascript that will interact with the JQuery plugin (definition of a JSON object).

display: function (personData) {
var $img = $('<img src="mysite/javascript/phone.jpg" title="Edit phone numbers" />');
return $img;

There is a var $img defined in which a string is passed to $(). Later on in the code, we will use this defined variable to link it with a click event :
$ { something...)

I constantly get a syntax error on the line which defines this variable $img :

Parse error: syntax error, unexpected T_STRING in ...
This indicates that there is a problem with unescaped quotes. But when I escape the innerquotes, I get following error :

missing variable name[Afbreken op deze fout]
var = $('<img src="mysite/javascript/phone.jpg" title="Edit phone numbers" />')

It looks as if this is purely a JQuery problem and should not be expressed in this forum. That's why I waited 2 days while I looked over the internet for a solution and applied possible solution (escaping, changing quotes,changing the sequence of the needed libraries...). Nothing worked. Could it be perhaps possible that there is a sort of conflict here ?