placeholders to variable not working

Questionsplaceholders to variable not working
Rob asked 11 years ago

I'm trying to assign a placeholder to a variable inside the cols1[] and it's not working. Placeholders will work inside of col["links"] but not directly to a variable.. Am I missing something?

$col1 = array();
$col1["title"] = "Order #";
$col1["name"] = "orderid";
$col1["width"] = "20";
$col1["editable"] = true;
$orderid = "{orderid}"; <<—— Not working
$cols1[] = $col1;

$col1 = array();
$col1["title"] = "BOL"; // caption of column
$col1["name"] = "bolnumber"; // grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col1["width"] = "10";
$col1["editable"] = false;
$col1["link"] = 'javascript:window.open("assignbol.php?order={orderid}","newwind","height=800,width=800"); void(0);';
$cols1[] = $col1;

4 Answers
Abu Ghufran answered 11 years ago

To use placeholder in any column display, you need to use 'default' property.

$col["default"] = "order id : {orderid}";

Abu Ghufran answered 11 years ago

In your case it would be $col1["default"] = "order id : {orderid}";

Rob answered 11 years ago

I'm sorry, I guess I should have explained by intentions for the variable. I'm trying to execute a mysql variable before the 2nd column. It's going to see if there is a bol number assigned, if not it's going to return a different link in the 2nd column. I've tried a bunch of different ways and can't get orderid to return any value. Here is my current code:

$col1 = array();
$col1["title"] = "Order #";
$col1["name"] = "orderid";
$col1["width"] = "20";
$col1["editable"] = true;
$ordid = "{orderid}";
$cols1[] = $col1;

$result = mysql_query("SELECT * FROM boltracking WHERE ordernum = '$ordid'") or die(mysql_error());
while($row = mysql_fetch_array( $result )) {
$bolnum = $row['bol_num'];
}
if ($bolnum == "") {
$bolnum = "Assign";
}

$col1 = array();
$col1["title"] = "BOL";
$col1["name"] = "bolnumber";
$col1["width"] = "10";
$col1["editable"] = false;
$col1["default"] = $bolnum;
if ($bolnum == "Assign") {
$col1["link"] = 'javascript:window.open("assignbol.php?order={orderid}","newwind","height=800,width=800"); void(0);';
} else {
$col1["link"] = 'javascript:window.open("bolmaker.php?order={orderid}","newwind","height=800,width=800"); void(0);';
}
$cols1[] = $col1;

Abu Ghufran answered 11 years ago

You can try column event of on_data_display. Example code is mentioned on link.

http://pastebin.com/5APKEWTR

I've not tested this code and it is just to give you idea of usage.

Your Answer

13 + 20 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?