This does not work, may be because it is C# V6 and this is not supported.
Now I want to put this in more than one line of code in RADZEN editor, but I cannot get this to work. I get an error message during code generation. Is this possible or do I have to write a method in a file which extends the partial class of my page?
I looked at your question. What I am trying to achieve is very similar. Yet, being at the very beginning of the learning curve, I struggle getting the right syntax. Hopefully you can help.
I have a datagrid with form displaying opportunities. Every time I select an opportunity, I would like a numeric box to return a field value name WeightedAmount from a view called Pipeline and store the value into WeightedCashflow for display, knowing that the opp id is the same than pipeline.id
Within the SelectRow event of the datagrid, I am doing the following:
invoking the datasource to assign getPipelinesResult to ${result}
Execute C# with weightedcashflow = getPipelinesResult.WeightedAmount.where(m => m.id == ${opp.id});
I get the following error message: 'IEnumerable' does not contain a definition for 'WeightedAmount' and no accessible extension method 'WeightedAmount' accepting a first argument of type 'IEnumerable' could be found (are you missing a using directive or an assembly reference?) [/Users/fr3dk/Documents/Perso/ Salesmetry/Radzen/server/Dashboard.csproj]
@FredK_Trashmail the compiler error tells it all - the getPipelinesResult property is a collection of Pipelines objects and it doesn't have the properties of the Pipeline itself (WeightedAmount).
I was thinking that the ${result} was containing some sort of image of the table.
From what you said, I understand I should look for a way to access the Pipeline properties directly.
Is there anything I could read to get to the result I am aiming ?
You need to somehow get a single item from that result. Either use the getXXXById data source method which returns a single record from a table or get an item from the getPipelinesResult property itself. In any case inspecting the code that Radzen generates would help you understand what the data source methods return.
Thank you Korchev,
will try this. On your second suggestion, this is what I try now and then, including the CRM samples, but that's still a stretch for me at this stage.
Went through all the 6 forum threads where getXXXbyId is mentioned but did not see any example on how this can be defined using the tool,
Found some references to it in the Edit Data Items section of the documentation BUT realised it does not seem to apply to Views (I made sure the view was invoked at Page level).
So that doesn't work.
Tried to look at getting to the property itself but likely beyond my ability at this stage.
So I figured out I could:
at the datagrid RowSelect event level, get Pipeline result filtered with id equals ${opp.id}
set a property where FilteredPipeline value is result.First()
assign the numeric box value to the ${filteredpipeline.weightedamount}
No error message but system was hanging and not letting me access the Opportunity page. I thought the filter was causing the issue so removed it. Same hanging
It is a bit surprising because I use this trick of result.First() in other pages (not in a datagrid event though) and it works as expected.
Hi Fred, had no time to respond yet. Presently I am on holidays. When application seems to get stuck, normally an exception happened. Have you tried to open it in visual studio and run it from there? Very often you find more information there what is going on. You can also turn first chance exceptions on in visual studio. This will bring up much more exceptions, that do not matter but it also helps to identify hidden exceptions like type conversion problems or SQL errors.
Issue fixed. It was hanging because on the first time the page is displayed, ${FilteredPipeline.WeightedAmount} is not known as there is no RowSelect event taking place prior to first rendering.
Defining the same Invoke from Data Source and setting FilteredPipeline property at the page level fixed this issue.
I took a more hardcore approach, following your indication that reloading the grid will not reload the data from the database. Once the record is updated and notified as such, I reload the entire dataset (in the templateForm Submit event), assign the result to ${result} and ask the grid to reload. I imagine this is somehow what happens as part of any Page Load sequence.