rbroder
Posts: 67
|
| Posted: 06/14/2010, 2:30 PM |
|
Can you use Ajax autocomplete and autofill in an editable grid or only in a record form? When I try to use it on a textbox in the grid, nothing happens when I type in the field in runtime.
|
 |
 |
andy
Posts: 183
|
| Posted: 06/14/2010, 3:56 PM |
|
I worked out a way of implementing autofill in editable grids.
See this post: http://forums.codecharge.com/posts.php?post_id=110410
However, Support provided me with a patch that supports autofill in editable grids... not sure whether this has been generally released since??
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
 |
 |
andy
Posts: 183
|
| Posted: 06/14/2010, 4:02 PM |
|
Just checked. Last release of CCS was Feb 2010.
Support emailed me the patch in April 2010.
Contact Support and ask them to send you the patch (Components983943393.zip containing PTAutoFill.ccl)
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
 |
 |
rbroder
Posts: 67
|
| Posted: 06/15/2010, 1:51 PM |
|
Thank you. Does the version 4.3.00.7676 automatically come with the patch, or did the patch bring the version number up, or has the patch been added to that version?
|
 |
 |
andy
Posts: 183
|
| Posted: 06/16/2010, 2:57 AM |
|
I think it is a special patch that is NOT included in 4.3.00.7676
If you contact support they may send it to you.
Presumably they are going to include it in the next release???
_________________
Andy
RAD tools for rich UI controls:
http://www.koolphptools.com |
 |
 |
rbroder
Posts: 67
|
| Posted: 06/16/2010, 9:00 AM |
|
Thanks Andy. I submitted my request to tech support and they responded that the Yahoo UI library will work from and editable grid.
I made the change and now everything works correctly. As I wrote them, the documentation makes no recommendation on which library to use. It might be worthwhile if they rewrote the Ajax section to mention that Autocomplete doesn't work in an editable grid and Yahoo UI does.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 06/17/2010, 11:08 AM |
|
Well, I guess this thread is not yet complete. While Autocomplete does indeed work, Autofill is using the protype library and DOESN'T work in an editable grid. I will be asking support again for the patch.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 06/24/2010, 11:57 AM |
|
I got the patch but can't make autofill work. I guess Autofill is using the new library, but I have no way to verify this: you can't pick the library in AutoFill, just autocomplete. I set an Ajax Condition1 as a feature on the Company_Name field to check for a non-empty field. Then I set the autofill start condition to look to at Condition1.ontrue. Autofill is set to collect the ID from the customer table and populate the companyID field on the form. I have made sure to include the {masterlog:rownumber} i when calling out the fields.
Sound right? It sure won't work.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 06/24/2010, 11:57 AM |
|
I got the patch but can't make autofill work. I guess Autofill is using the new library, but I have no way to verify this: you can't pick the library in AutoFill, just autocomplete. I set an Ajax Condition1 as a feature on the Company_Name field to check for a non-empty field. Then I set the autofill start condition to look to at Condition1.ontrue. Autofill is set to collect the ID from the customer table and populate the companyID field on the form. I have made sure to include the {masterlog:rownumber} i when calling out the fields.
Sound right? It sure won't work.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 07/01/2010, 2:25 PM |
|
<b>I have finally got the autofill to work completely.</b> There is a good post in the php forum located here: http://forums.yessoftware.com/posts.php?post_id=97313.
I used that post and more. My problem was trying to use the result of a text field autocomplete (CompanyName) as the source for the autofill of another text field (CompanyID) in the same record. In my case the autocomplete is used to maintain consistent spelling, as the Company Name text is copied (if it exists) from the Company table and stored with the MasterLog record. The Autofilled CompanyID is used during the record insert to see if a new Company record had to be created (i.e. no CompanyID data).
Here is the code snippet to get the AutoFill to work:
<code>
function masterlogCompanyNamePTAutoFill1_start(sender) {
// get the row indentifier which is the number after the last underscore
var id_index = sender.id.lastIndexOf("_")+1;
var row_id = sender.id.slice(id_index);
new Ajax.Request("../services/TechResolutionTracker_IssueInput_masterlog_CompanyName_PTAutoFill1.php?keyword=" + $("masterlogCompanyName_" + row_id").value, {
method: "get",
requestHeaders: ['If-Modified-Since', new Date(0)],
onSuccess: function(transport) {
var valuesRow = eval(transport.responseText)[0];
if (typeof(valuesRow) != "undefined") {
getSameLevelCtl("masterlogCompanyID_" + row_id, sender).value = valuesRow["ID"];
} else {
getSameLevelCtl("masterlogCompanyID_" + row_id, sender).value = "";
}
},
onFailure: function(transport) {
alert(transport.responseText);
}
});
}
//End PTAutoFill1 Loading
</code>
The example in the original post referenced above had different syntax for the Ajax.Request call. It took me a while to figure out what would work. Note the use of the <b>row_id</b> variable in 3 different places in my code snippet.
In the <b>Before Execute Insert</b> of the MasterLog record, I check if the CompanyID field is empty. If so, I use a procedure to insert the name into the company table, then get its CompanyID back from the Company table. Then I use that number to populate the CompanyID field in the MasterLog record and complete the insert.
<code>
if ($Container->CompanyID->GetValue()=="")
{
//update the Customer Table
$db = new clsDBTechResolutions;
$NewCustomer = $Container->CompanyName->GetValue();
$SQL = "INSERT INTO tblcustomer (CustomerName) VALUES(".$db->ToSQL($NewCustomer,ccsText).") ";
$db->query($SQL);
//retrieve the company ID for use in this form
$newid = CCDLookUp("ID","tblCustomer","CustomerName = " .$db->ToSQL($NewCustomer,ccsText),$db);
$Container->CompanyID->SetValue($newid);
}
</code>
As a side note: I have 2 AutoComplete fields on the page. One used in the search pane, and one in the MasterLog pane. When I tried to implement the one in the search pane, the code wouldn't work. I found that the wizard failed to put in a line in the html to Bind to the AutoComplete function. After I manually added the statement, everything worked.
<code>
//bind_events @1-5A1C1E06
function bind_events() {
masterlogSearchs_Company_NamePTAutocomplete1_start();
masterlogCompanyNameYahooAutocomplete1_start();
addEventHandler("masterlogCompanyName", "blur", masterlogCompanyNamePTAutoFill1_start);
addEventHandler("masterlogCancel", "click", masterlogCancel_OnClick);
addEventHandler("tbldetailsCancel", "click", tbldetailsCancel_OnClick);
}
//End bind_events
</code>
I hope this helps with all you frustrated CCS programmers.
|
 |
 |
rbroder
Posts: 67
|
| Posted: 07/01/2010, 2:25 PM |
|
<b>I have finally got the autofill to work completely.</b> There is a good post in the php forum located here: http://forums.yessoftware.com/posts.php?post_id=97313.
I used that post and more. My problem was trying to use the result of a text field autocomplete (CompanyName) as the source for the autofill of another text field (CompanyID) in the same record. In my case the autocomplete is used to maintain consistent spelling, as the Company Name text is copied (if it exists) from the Company table and stored with the MasterLog record. The Autofilled CompanyID is used during the record insert to see if a new Company record had to be created (i.e. no CompanyID data).
Here is the code snippet to get the AutoFill to work:
<code>
function masterlogCompanyNamePTAutoFill1_start(sender) {
// get the row indentifier which is the number after the last underscore
var id_index = sender.id.lastIndexOf("_")+1;
var row_id = sender.id.slice(id_index);
new Ajax.Request("../services/TechResolutionTracker_IssueInput_masterlog_CompanyName_PTAutoFill1.php?keyword=" + $("masterlogCompanyName_" + row_id").value, {
method: "get",
requestHeaders: ['If-Modified-Since', new Date(0)],
onSuccess: function(transport) {
var valuesRow = eval(transport.responseText)[0];
if (typeof(valuesRow) != "undefined") {
getSameLevelCtl("masterlogCompanyID_" + row_id, sender).value = valuesRow["ID"];
} else {
getSameLevelCtl("masterlogCompanyID_" + row_id, sender).value = "";
}
},
onFailure: function(transport) {
alert(transport.responseText);
}
});
}
//End PTAutoFill1 Loading
</code>
The example in the original post referenced above had different syntax for the Ajax.Request call. It took me a while to figure out what would work. Note the use of the <b>row_id</b> variable in 3 different places in my code snippet.
In the <b>Before Execute Insert</b> of the MasterLog record, I check if the CompanyID field is empty. If so, I use a procedure to insert the name into the company table, then get its CompanyID back from the Company table. Then I use that number to populate the CompanyID field in the MasterLog record and complete the insert.
<code>
if ($Container->CompanyID->GetValue()=="")
{
//update the Customer Table
$db = new clsDBTechResolutions;
$NewCustomer = $Container->CompanyName->GetValue();
$SQL = "INSERT INTO tblcustomer (CustomerName) VALUES(".$db->ToSQL($NewCustomer,ccsText).") ";
$db->query($SQL);
//retrieve the company ID for use in this form
$newid = CCDLookUp("ID","tblCustomer","CustomerName = " .$db->ToSQL($NewCustomer,ccsText),$db);
$Container->CompanyID->SetValue($newid);
}
</code>
As a side note: I have 2 AutoComplete fields on the page. One used in the search pane, and one in the MasterLog pane. When I tried to implement the one in the search pane, the code wouldn't work. I found that the wizard failed to put in a line in the html to Bind to the AutoComplete function. After I manually added the statement, everything worked.
<code>
//bind_events @1-5A1C1E06
function bind_events() {
masterlogSearchs_Company_NamePTAutocomplete1_start();
masterlogCompanyNameYahooAutocomplete1_start();
addEventHandler("masterlogCompanyName", "blur", masterlogCompanyNamePTAutoFill1_start);
addEventHandler("masterlogCancel", "click", masterlogCancel_OnClick);
addEventHandler("tbldetailsCancel", "click", tbldetailsCancel_OnClick);
}
//End bind_events
</code>
I hope this helps with all you frustrated CCS programmers.
|
 |
 |
|