How to unset relation in 'find'? - mongodb

I have content type "Novel" and have relation with "Tag" and "Genre", I want to only show "Tag" and "Genre" in 'findOne' but not in 'find'. using m.unset in models/Novels.js only working if the data is not relation. how can I un-populate this Tag in 'find'?

You can deal with that by updating the find function of the Novel API.
📚Here is the documentation to update the controller function https://strapi.io/documentation/3.0.0-beta.x/guides/controllers.html
You will have to copy and past the find function code.
And replace return strapi.services.product.find(ctx.query); by return strapi.services.product.find(ctx.query, []);
We add an empty array because the second argument is here to specify data you want to populate. By passing an empty array you say to not populate data.

Related

Data in array collection shows empty when retrieving info

I'm creating a web app with symfony. I'm currently building the forms and as I've never used the ManyToMany relation I'm having some problem with retrieving the information.
The form I'm working with is this one:
The point is that when I'm retrieving the information of the array in the twig template, the data property inside the array shows empty, when there is Alumne's entities created. Let me show you.
Twig template (create page):
As you can see, what I pretend is to retrieve the info of every Alumne entity inside the array.
What I get doing this is:
The alumnes field is completly empty. But if I change the form Builder to this:
(I have also changed a little bit the twig template to make it more readable)
It works!
And as you can see there is an Alumne created.
The point is, as you can see, the select and option tag it creates is kinda ugly, I want to custom so it can fit the rest of the forms. So that's why I need a CollectionType in the builder and I don't know what I'm doing wrong. Also if I check the dump(form.alumnes.vars.data) it shows empty.
The issue here is, that you use the CollectionType instead of the EntityType. To load data from the Database into a form, you should use the EntityType https://symfony.com/doc/current/reference/forms/types/entity.html
If you leave the type out, Symfony will try to guess what form element to use and will (correctly) guess the EntityType

How to retrieve the rows which are selected in the list report page of smart templates

This is the List Report type of Smart Template application
Here I have selected 2nd and 5th row, I also have a button named Send Requests in the section part which is highlighted. If I click this button it calls a javascript controller function which is defined in the extensions of the application. In this js function how can I retrieve the selected rows that are selected?
I have enabled the checkboxes in this page by mentioning this code
"settings": { "gridTable": false, "multiSelect": true } in the manifest.json
As it was recommended by this link https://sapui5.netweaver.ondemand.com/#docs/guide/116b5d82e8c545e2a56e1b51b8b0a9bd.html
I want to know how can I retrieve the rows which got selected?
There is an API that you can use for your use case. It is described here: https://sapui5.netweaver.ondemand.com/#docs/guide/bd2994b69ef542998becbc69ab093f7e.html
Basically, you just need to call the getSelectedContexts method. Unfortunately you will not be able to really get the items themselves, only the binding contexts (which point to the data entities which are selected). Excerpt from the documentation:
After you have defined a view extension, you can access and modify the
properties of all UI elements defined within these extensions (for
example, change the visibility). However, you cannot access any UI
elements that are not defined within your view extensions.
In this type of table there is way.
var myTable=sap.ui.getCore().byId("your table id");
get all rows:
var myTableRows=myTable.getRows();
now get selected Indices
var selectedIndeices=myTable.getSelectedIndices(); //this will give you array of indeices.
now run loop on indeices array. And get particular row item;
// get binding path
var bindingpath=myTableRows[2].getBindingContext().sPath; // this will return eg:"/ProductCollection/2"
// now get Binding object of that particular row.
var myData=myTableRows[2].getModel().getObject(bindingpath); // this will return binding object at that perticular row.
// once your loop is over in the end you will have all object of selected row. then do whatever you want to do.
If you use smart template create an extension.
This is the standard event befor the table is rebinding:
onBeforeRebindTableExtension: function (oEvent) {
this._table = oEvent.getSource().getTable();
}
In your action function (or where you want) call the table and get the context :
this._table.getSelectedContexts();

How to create a display,or similar, method with paramater?

in my myForm I call in a tableMY a displayMethod_fieldA.
In myForm I insered a some date in a DateEdit and I want to make a selection in table using the entered value. If I crete a displayMethod whit parameter I have an error.
Look like this code I get error:
display myEDTField displayMethod_fieldA (date _dateFromForm)
{
tableMY table;
select table
where table.item == this.item
&& table.dateTable == _dateFromForm;
return table.valueFieldA;
}
I have an error looklike this:
The display method has an incorrect parameter profile.
There is another way to display or set the value in my StrinEdit in Grid by method passing a parameter?
In web I saw the method modifier modifierMothod , but I need some more explanation. I don't know if this method is a right way.
Display methods are not designed with this feature.
display method for a table, form, report, or report design does not
have any parameters. For example: display Amount amount()
A display method for a form data source does require a parameter. You
use the
parameter to specify a table buffer. The type of the table buffer has
to match the type of the table in the form data source.
https://msdn.microsoft.com/en-us/library/aa595058.aspx
You can create the desired behaviour with an edit method (and setting the field to AllowEdit(false) or enabled(false).

return multiple columns from stored procedure in MVC

Was previously using this line in my controler to return an id and text column from, a stored procedfure in asp.net MVC
user = new SelectList(ctx.Database.SqlQuery<LkUpGenderModel>("EXEC dbo.uspGetLkUpGender").ToList(), "GenderID", "Gender");
However i now want to return more text values, I have extended the model to have these extra fields but I'm getting an error.
Is there a way to get this working:
user = new SelectList(ctx.Database.SqlQuery<LkUpGenderModel>("EXEC dbo.uspGetLkUpGender").ToList(), "GenderID", "Gender", "GenderShort", "GenderCombined");
currently it flags the SelectList( saying the call is ambiguous
The previous code simply returns instances of LkUpGenderModel and then builds a SelectList from that using the GenderID property of that class as the value and the Gender property as the display text.
Your new code doesn't request more properties, it simply passes additional parameters to the SelectList constructor: namely, dataGroupField which you're setting to the GenderShort property, and selectedValue, which you're setting to the GenderCombined property. See: https://msdn.microsoft.com/en-us/library/dn725507(v=vs.118).aspx.
If you have additional columns being returned from the stored procedure that you want filled in on the class, then you should add additional properties to the class to handle those. However, since all you're doing with the data is creating a SelectList from it, you can't send any additional data to the view other than the value and display text, making returning additional data pointless in this instance.

Autocompleter for Mootools to set multiple form values

I need a Mootools based autocompleter that retrieves data by ajax, and will fill in multiple form input elements when an option is selected. I.E, a user searches for "foo", and one of the options might be "foobar", which has associated with it the variables objecttype AND objectid, both of which need to be set in the form when the user clicks on "foobar".
I've been looking at two autocompleters: Meio.Autocomplete and AutoCompleter as my best bet, but neither of them really seem to handle what I need them to handle.
I'm considering either rewriting/extending one of those, or possibly using the Meio version (which handles a single value) and storing my multiple variable in the form in one field, possibly as a json object that can be parsed client side with jsonParse and inserted into the form with an additional function after the selection is made.
Does anyone know of a simpler solution?
You could use the Meio.Autocomplete's onSelect event with an identifier, that JSON encodes all of the needed properties.
var data = [
{value: 'name1', identifier: {
id: 'id1',
type: 'type1'
}},
...
}
I made a quick example