Custom Button to call php API in main form or any alternative option

2 posts, 0 answers
  1. Kanwar
    Kanwar avatar
    1 posts
    Member since:
    Aug 2013

    Posted 12 Sep 2013 Link to this post

    Hi I've got a php form that I've modified with a Kendo Grid. (Please see attachment below).

    What I would like to do

    a) Invoke a PHP function on Click of the Custom Button in the Grid.
    b) Pass value from javascript/ajax back to the PHP page such that it recognizes it as a Post when the button is clicked.
    c) The function in PHP in turn calls a Cloud API , want to invoke this cloud API from the same button click function.

    Kanwar Batra

    PS : This is the last validation step for me to confirm to my customers and peers to use your interface without this we are unable to move forward
  2. Petur Subev
    Petur Subev avatar
    1882 posts

    Posted 16 Sep 2013 Link to this post

    Hello Kanwar,

    Basically to invoke a function from a button in the Grid can be achieved in several ways:
    1. Create command button like explained here:
    2. Use template (the link included an example how to Invoke JS function) column to create the button on your own and invoke a JavaScript function passing the parameter to it. 
      "<buttom class='myClass' onclick='someFunction(#= ColumnNameThatYouNeed#)'>Some Text that you want</button>"

            function someFunction(theId){
                 //... perform your own $.post here

    3. Create template button like above with a class and use delegate event to handle it with combination of the dataItem method of the Grid. 
      template: "<button class='mySpecialButton'>Some Button again</button>"
               var model = $('#gridName').data().kendoGrid.dataItem($(this).closest('tr'))
               //... perform your own post again

    Kind Regards,
    Petur Subev
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET AJAX banner
Back to Top