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.
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
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.
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.
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...
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 ?
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.
AFAIK the write function even returns the ID, so you should be able to
$ID = $myObject->write();
if (!empty($ID)) ...
Yes martimiz is indeed correct, write() does return the ID so it's there for you to grab directly from the function.
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).
Requirements::customScript("
...
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 :
$img.click(function() { ....do 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 ?