| Recommend this page to a friend! |
| DrasticTools | > | All threads | > | addparams | > | (Un) Subscribe thread alerts |
| |||||||||||||||
I was advised that passing the where clause should use the addparams options.
I am giving a try using example9.php On the 9.php file, i try to pass Country and Name as follows: addparams:"&tablename=country&Name=Andorra" Part of the function in the example9.php: function rebuild_table() { if (thegrid) $('grid1').empty(); thegrid = new drasticGrid('grid1', { pathimg:"img/", pagelength:10, addparams:"&tablename=country&Name=Andorra" }); } Part of the drasticSrcMySQLExampleGrid9.class.php: around line 60, i added: $Name = $_REQUEST["Name"] as follows: // Optionally retrieve parameters from the addparams parameter. // Uncomment the line below and change "myparameter" to the name of your // parameter // If you pass multiple parameters copy the line multiple times // $myparameter = $_REQUEST["myparameter"]; // $Name = $_REQUEST["Name"]; $tablename = $_REQUEST["tablename"]; When i try to browse example9.php, the same output are display. It does not restrict the output to show name only Andora, although it does restrict to using the table Country. i.e. the first paramter works but not subsequent parameters under: addparams:"&tablename=country&Name=Andorra" So where should i use the passed param in drasticSrcMySQLExampleGrid9.class.php to implement the SQL where clause? Thanks a million for your time. Rgds panac
Dear panac,
In your code you do indeed pass the Name variable to the php code. But within the php code nothing happens with it. Passing a variable + value with addparams just passes it to the php context. In order to let the Name variable restrict the select statement you can pass the Name variable to the "defaultcols" setting, as follow: // Optionally retrieve parameters from the addparams parameter. // Uncomment the line below and change "myparameter" to the name of your // parameter // If you pass multiple parameters copy the line multiple times // $myparameter = $_REQUEST["myparameter"]; // $Name = $_REQUEST["Name"]; $tablename = $_REQUEST["tablename"]; //Then Add this: $this->defaultcols["Name"] = $Name; Hope this helps, good luck, drasticdata
Thank you. It works prefectly base on your clear instructions.
One more final touch, how to we rename the column? I can't find the rename col option in the class, is it supported ? drasticSrcMySQLExampleGrid9.class.php: function __construct($server, $user, $pw, $db, $table, $options = null) { if (!isset($_REQUEST["op"])) return; if ($options) { if (isset($options["add_allowed"])) $this->add_allowed = $options["add_allowed"]; if (isset($options["delete_allowed"])) $this->delete_allowed = $options["delete_allowed"]; if (isset($options["editablecols"])) $this->editablecols = $options["editablecols"]; if (isset($options["defaultcols"])) $this->defaultcols= $options["defaultcols"]; if (isset($options["sortcol"])) $this->sortcol= $options["sortcol"]; if (isset($options["sort"])) $this->sort= $options["sort"]; if (isset($options["SQLCharset"])) $this->SQLCharset= $options["SQLCharset"]; if (isset($options["HTMLCharset"])) $this->HTMLCharset= $options["HTMLCharset"]; }
Great.
Well, the renamecol option is no longer supported in the php class. Instead, you can control the label of the column to be displayed via the 'displayname' variable in the 'columns' option in the drasticgrid, like this: var thegrid = new drasticGrid('grid1', { pathimg:"img/", pagelength: 10, columns: [ {name: 'id', width: 40, displayname: 'myname'}, {name: 'name'}, {name: 'email', type: DDTYPEMAILTO, width: 140, editable: false}, {name: 'www', type: DDTYPEURL, width: 180, editable: true}, {name: 'present', editable: false} ], sliderposition: "left", onClick: function(id){thegrid.DefaultOnClick(id); alert('clicked on row with id = '+id)} }); good luck, Drasticdata
Thank you so much, it worked!
Your answer solved my many days of research and trial and error. I also see there is a possibility to use the event to validate the data: //Events: onAddStart onAddComplete onDeleteStart onDeleteComplete onUpdateStart onUpdateComplete Do you have at least 1 example on that? I tried reading the documents and examples, but none explain how to use it. Thank you, once again. panac
Hi panac,
The implementation of the events is still incomplete. That's why there are no examples of it's use. However, you can use the events you mentioned as you wish, because they are being fired. To look how they should work, you may look at the implementation and use of the onDeleteStart event. That event is used to ask a question if the record should be deleted and if not, it does not proceed deleting the record. The other events could be used the same way, but I must say to use them for validation, they should actually be extended to provide a way to NOT proceed adding, or changing the record and that is not yet implemented as it is for ondeleteStart. You may do it yourself or alternatively wait for the next version. I put it on the wish list..... regards, DrasticData
Thanks DrasticData. I will give it a try, at least
i know where to start. Keep up the fantastic work. Cheers Panac
Hi, I'm also trying to perform the operation you are doing using addparams. However, I am not having success. Can you share some of the code with me that shows how you added the addparams, this->defaultcols. Where were they placed.
Thanks Ken |
info at phpclasses dot org.
