2/22/2025 8:00:15 AM
|
|
slxdeveloper.com Community Forums |
|
|
|
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
Forum to discuss using & developing the legacy SalesLogix Web Client (For versions 7.0 and earlier). View the code of conduct for posting guidelines.
|
|
|
| |
|
Re: in script how do I get a column value from a selected row in a query
Posted: 16 Dec 06 1:48 AM
|
fiogf49gjkf0d Just remember that at this point you are just dealing with a Table.
I don't have a Web Client in front of me to test, but:
- The Grids (tables) have a behavior attached to them. If you read thru the codes you will notice how the system selects the existing row. Not sure if there is a variable being set, if so it could be utilized. - If you get a reference to the row, you should be able to query the do something similar to table.rows(x).column(y) [You probably need to offset for header rows and hidden columns]. Now you probably need to run this into the debugger to view what are the contents of the cell. Depending on the field type, formatting, etc there could be several items within that column, so you would have to pick the correct one.
Seems difficult, but I got to say its very simple to achieve. I will try to get you code samples if I get to a Web client before someone else does. |
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 18 Dec 06 10:35 PM
|
fiogf49gjkf0d Steve,
Don't know if you got it working, but I'll give you an example. First, on the layout tab of the query "con_con", modify the ONROWSELECT markup/value pair so it reads like this:
"rowSelected(event.rowIndex); myfunction(event.rowIndex);"
That will call the JS function "myfunction", passing in the index of the row that was clicked. You can then use that index to get the value from the table.
Next, on the template searchcondata, add this javascript function in the script tag at the top:
function myfunction(rowIndex) { alert(document.all.CONRESULTS.rows[rowIndex].id); }
That should do it. The PK for the row is returned in the property "id" of the < TR > tag.
Jeff |
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 18 Dec 06 11:03 PM
|
fiogf49gjkf0d Steve,
I seem to have this problem of not reading correctly lately. I don't think I answered your question.
Using the con_con query again, all you have to do is add this in the function I wrote in the post above:
alert(document.all.CONRESULTS.rows[rowIndex].cells[5].innerText)
That will get & alert the work phone. The caveat is that if you change column positions, things break, because it's hard-coded to column 5. If you don't want to hard-code, there is a way around it.
Using the query con_con (again), go to the layout tab and select "Col 5: Contact Phone (Work)". Add the following markup/value pair: markup=id; value=workphone.
Then modify the function "myfunction" like this:
function myfunction(rowIndex){ var grid = document.all.CONRESULTS; for (y=0; y<=grid.rows[rowIndex].cells.length-1; y++) { if (grid.rows[rowIndex].cells[y].id == "workphone") alert(grid.rows[rowIndex].cells[y].innerText); } }
By adding the ID markup/value pair, if you move the column in the grid, the code doesn't break.
Jeff
|
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 19 Dec 06 8:43 AM
|
fiogf49gjkf0d Jeff, thanks for the help. I think I got it figured out with the assistance, however I'm getting an error stating that the function(myfunction) is undefined. Not sure why it is not loading the jscript. seems like any custom function that I put in the Markup for ONROWSELECT it is failing to find the function in the HTML page.
Should I be adding the Function in the query header instead of the the file directly? |
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 19 Dec 06 10:50 AM
|
fiogf49gjkf0d Steve,
The function should be on the page itself, not in the query object. I suppose it could go in the query header if you embed it within a script tag. I think in 6 years, though, I've only used the query header/footer once.
Since the JavaScript is case sensitive, make sure that what is in the query markup/value pair matches what is on the page. You could try putting debugger in the markup/value and jump into a debugger to see what page you're on to make sure you're on the page you think you are. It would look something like this:
"rowSelected(event.rowIndex); debugger; myfunction(event.rowIndex);"
That should jump into the debugger on the page that your query object is on and you can make sure the function is there. If you don't want to use the debugger, if you do a "view source" on the page, is the function there?
You could try removing the markup from the query object and then add a < body > onload statement on the HTML page that calls 'myfunction' to see if you can get it to call that function, but not from the query - that way you'll know you can call it.
Let me know if that doesn't help.
Jeff
|
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 19 Dec 06 11:56 AM
|
fiogf49gjkf0d I had it in the script debugger earlier and it looks as if the function is there, but stills gives the invalid object. I've tried adding it to the header of the query instead of to the page directly and I had the same result. Now my script debugger is not opening on the error and I'm not sure had changed. I wil try your suggestion adding it to the Markup tag. |
|
|
| |
|
Re: in script how do I get a column value from a selected row in a query
Posted: 19 Dec 06 2:28 PM
|
fiogf49gjkf0d Ok All, I got the Scripting to grab the id Value out of the Selected Row. Now back to my Original post. How can I reset the conditions on the second query when the row on the first record changes. I setup a Condition on the query and I'm Calling it by typeid and value when the initial query table is populated. I figure I need to put it in a frame and change the value on the frame based on the value pulled from the selected row on the first query
right now my two queries set side by side on an account tab view. |
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 19 Dec 06 4:52 PM
|
fiogf49gjkf0d Steve,
If I understand things correctly, you get the value from the first query and want to reload the second query based on what's in the first?
You have two ways of doing it. You can reload the current page in JavaScript by calling the URL of the page again, but this time passing in the values on the URL to your query. For example, if one of your query conditions is where "accountid = :accid", you can simply pass in the value accid on the query string, like this:
document.location.href = "<#SYS name=swcpath>/view?name=&accid=ABCDEFGHIJKL
If your query has a parameter named "accid", it will pull the value from the URL. If you do it this way, though, you'll need to pass the current value for the first query and the value you need for your second query that you gathered from the user clicking a row.
The other way that you suggested is what I've done before, and that's have a frameset and you reload the second frame with your second query. Just pass the query values along the URL as in the first method. Just make sure you have a name/value pair on the URL that matches your parameter name (i.e. ":yourvalue") in your query object.
Make sense? Or clear as mud?
Jeff
|
|
|
|
Re: in script how do I get a column value from a selected row in a query
Posted: 20 Dec 06 6:44 AM
|
fiogf49gjkf0d Makes perfect sense, I've started working on the Frame set idea first. that way the whole view doesn't refresh, although the other way is probably easier. This way if there are a lot of rows in the first query it won't take for ever, also then you would need to play with the selected row to make sure it stays highlighted after the reload. |
|
|
| |
|
You can
subscribe to receive a daily forum digest in your
user profile. View the site code
of conduct for posting guidelines.
Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
|
|
|
|
|
|
|
|