Trying to have a datagrid column expression be a dynamically built htmldropdown, with a datasource of a dynamically built collection (oOptions), based on data in the current record.
What I'm trying to do is have the oOptions collection object be built for each record in the grid based on a value in the current record.
So I tried to have the column expression create the oOptions object like this:
loColumn.Expression = [htmldropdown("lstActions",,'oOptions = createobj('coptions',<cursor.field>)','clink','caction',,"Available Actions","")]
But am running into eval issues during the HtmlDataGrid() call.
Is there a way to have a column expression, be a dynamically blt dropdown, based on a dynamically blt collection object?
Thanks, Doug
Please use the code formatting tools to format the code you post here... You can edit your existing post.
+++ Rick ---
I edited the original post.
It's usually better for more complex things to call a UDF() or method in the process class to handle the expression rather than try to debug this all inside of a string expression - the advantage is that you can set a breakpoint in the expression.
So create a method in the process class (or create UDF())):
FUNCTION GridDropDownList(lcFieldName)
LOCAL lcHTML
PRIVATE poOptions
poOptions = CREATEOBJECT(cOptions,lcFieldName)
lcHTML = htmldropdown("lstActions",,'poOptions','clink','caction',,"Available Actions","")
lcHtml =
ENDFUNC
Then use that in the column expression:
loColumn.Expression = "Process.GridDropDownList('FieldName')"
I'm not really sure what you're doing with your expression - not sure what the lcDataSource parameter is supposed to be, but that needs to be a cursor or collection to work.
+++ Rick ---
That did the trick 😃
The lcDatasource is poOptions. poOptions is a collection object blt dynamically based on the value of the passed in param to the createobj().
Thanks, Doug
Great - if I have expressions of any complexity I always create a function - it's much easier to reason about the code than trying to shoehorn inside of a string expression as I almost always mess up my quotes 😃
Hy Rick, I understand your point but on the other hand subclassing could also made sommetimes things easyer. I wrap all your HTML function in a view object . And use it this way in HTML
<%=PROCESS.oView.HtmlDataGrid(PROCESS.oModel) %>
View and model could be collections ..
Just my two cents, why not a fox document object 😃
PROCESS.oDoc.oGrid.oColumn etc ..
Sure I do the same in applications - I usually create a Model property and put all of my state and functions on that object and make that thing privcate:
<%= Model.Customer.oData.Name %>
<%= Model.Customer.CalculateOrderTotals() %>
While i think it's a good practice to do this, I also don't think it should be forced. There are many situations where you just need one or two values and there's no need to first create class - either a physical class that exists or a dynamically created EMPTY class.
If you want a more structured model for your controls etc. then you can look at the Web Control Framework, but frankly that model and the abstractions it forces are not always easier to work with.
Personally I like the MVC model because you have full control and you can pretty much accomplish a lot of what the WCF does with the HTML Helpers.
+++ Rick ---