Jump to:

23377 Posts in 18296 Topics by 2867 members

General Questions

SilverStripe Forums » General Questions » JQUERY JTABLE

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

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

Page: 1 2 3 4
Go to End
Author Topic: 7698 Views
  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: JQUERY JTABLE Link to this post

    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.

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: JQUERY JTABLE Link to this post

    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.

  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: JQUERY JTABLE Link to this post

    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
  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: JQUERY JTABLE Link to this post

    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 ?

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: JQUERY JTABLE Link to this post

    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.

  • martimiz
    Avatar
    Forum Moderator
    1068 Posts

    Re: JQUERY JTABLE Link to this post

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

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

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: JQUERY JTABLE Link to this post

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

  • sergieboy
    Avatar
    Community Member
    33 Posts

    Re: JQUERY JTABLE Link to this post

    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 ?

    7698 Views
Page: 1 2 3 4
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.