Answered by:
retrieve row count from subgrid

Question
-
Hi All,
I am trying to get the row count of a sub grid the problem we have is that the records in the subgrid can be deleted and they are a mandatory record so are needed by the end user, the code we have is that the record we need is auto-populated and then when saved and opened back up the record is then turned in to a sub grid which allows more records to be added to it.
I need to put a condition in that would stop the user from saving the form if there is no value saved in the subgrid.
I can get the sections back and the show stopper is that the section is called ServiceProviders which has 3 text boxes in and a subgrid called ServiceProvidersSubGrid then the box inside the subgrid is called ServiceProviders.
I hope that makes sense and that someone can help.
Regards
Aidan
Thursday, November 15, 2012 9:07 AM
Answers
-
Hi,
as I already mentioned, you can do this by retrieveing the records using a call to the REST Endpoint to get the related records.
Any other way would be unsupported, but if this is not a problem for you, you can take a look at this thread that has some sample code for it.
Greetings,
Pavlos
Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.
View my latest gallery contribution here.
Visit my blog here.- Marked as answer by Aidan Friday, November 23, 2012 10:50 AM
Thursday, November 15, 2012 9:22 AM
All replies
-
Hi,
I hope I understood your requirement correctly. Why don't you implement this in a plugin? You can register the plugin to the Create and Update messages in Pre-Operation stage and write the code that checks if there are any records in the subgrid relation. If not you can throw an error that will stop the record from saving while notifying the user with a simple error message.
Doing this in JavaScript will require you to make a call to the REST Endpoint to get the related records in the subgrid. You can get the row count also directly in JS, but this would require unsupported code.
Greetings,
Pavlos
Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.
View my latest gallery contribution here.
Visit my blog here.
- Edited by Pavlos Panagiotidis Thursday, November 15, 2012 9:16 AM
Thursday, November 15, 2012 9:13 AM -
we have been trying to do it through the JavaScript as this is how it has been presented to us to use. is there a way i can get a row count from the subgrid in JavaScript?
Regards
Aidan
Thursday, November 15, 2012 9:16 AM -
Hi,
as I already mentioned, you can do this by retrieveing the records using a call to the REST Endpoint to get the related records.
Any other way would be unsupported, but if this is not a problem for you, you can take a look at this thread that has some sample code for it.
Greetings,
Pavlos
Please mark this reply as an answer and vote it as helpful if it helps you find a resolution to your problem.
View my latest gallery contribution here.
Visit my blog here.- Marked as answer by Aidan Friday, November 23, 2012 10:50 AM
Thursday, November 15, 2012 9:22 AM