I am setting up an inventory app using the Voyager library, and want to add input classes for specific fields from $row->field. How to set it up in the edit-add blade file?
unfortunately it's not possible to add classes to BREAD fields yet. but actually there is an alternative way to achieve what you willing:
you can add an ID to field's container using BREAD display option
just goto bread > MODEL > edit > ATTRIBUTE and change its option details to
{
"display": {
"width": "3",
"id": "custom_id"
}
}
click Submit and it's done.
Related
I'm adding a new fields to my views through my custom module.
When I open up the views page UI, the field is not show up. However, If I edit the view on UI and click add field, I can see my custom field is available to add.
My question, how can I add automatically that field to the list of fields to display on the views?
function mymodule_views_default_views() {
...
$handler->display->display_options['fields']['myfield']['id'] = 'fieldname';
$handler->display->display_options['fields']['myfield']['table'] = 'databaseTableName';
$handler->display->display_options['fields']['myfield']['field'] = 'fieldname';
...
}
I have a project that sells products.
A product can have a price and optional: new_price. I would like to be able to sort them by price/new_price combined, meaning that I would need an additional entry in the DB like "final_price". I got an idea to create a non-editable field "new_price" in Content-Type Builder/schema.json and then update that with the final price for the product on "beforeCreate" in the lifecycles.js. However, I am not sure Strapi allows that, as I haven't been able to find a resource pointing in the documentation that it can. If there is a hacky way to do it, please advise. I am open to all kinds of other suggestions on how to do this Business logic as well.
Thank you in advance.
There is a way in strapi to make the field non editable on UI. You can go to Content-type-builder-> Your component-> Configure the view. And click on the text field. You can just make editable field as false.
I see two options:
(a) Add the field and forget about it being non-editable. You can calculate the final_price on insertion of an entry in your collection with Lifecycle hooks: https://docs.strapi.io/developer-docs/latest/development/backend-customization/models.html#lifecycle-hooks.
(b) Don't add a new field, but override the controller to return an additional field: https://docs.strapi.io/developer-docs/latest/development/backend-customization/controllers.html#extending-core-controllers.
Ok, so I found a "hacky" way to do this. I don't like it, as it is not that beautiful and sophisticated, but it does the job.
In product schema.json I added a
"final_price": {
"type": "decimal"
}
In lifecycles.js, I created a new function that will calculate my final price and write it in "final_price" attribute:
module.exports = {
beforeCreate(event) {
priceCalc(event);
},
beforeUpdate(event) {
priceCalc(event);
},
};
const priceCalc = (event) => {
const { data } = event.params;
data.final_price = data.new_price ? data.new_price : data.price;
};
In the admin panel, in Content-Type Builder in Product, I clicked "Configure the view" and deleted the Final Price field from Displayed Fields section. This made the field hidden, lol.
Now I am sorting all products with sort: ['final_price:asc']
That is it.Hope it helps anyone!
We are facing one issue with Kendo UI grid. (We are evaluating it, so no license copy as of now)
Scenario is:
We need to show data in Grid component.
For each column, we will have filter in form of multi select list box (see image attached).
We tried Kendo UI trial copy, and were successful to set data in it.
When we tried setting items in filter box, they appear to be blank.
Following is JSON which provides list of items in filter:
data which should be displayed in that dropdown list
[
{
"id": 67,
"name": "Investigation ESP"
},
{
"id": 88,
"name": "Refuse & Pickups"
},
{
"id": 101,
"name": "Dead Bug Removal"
}
]
Can you share proper example or point our mistake.
please try to combine the following two things...
http://demos.telerik.com/kendo-ui/grid/filter-menu-customization
http://www.telerik.com/forums/multi-select-with-checkboxes-plugin
Has anyone done anything with AngularJS and select droplists populating another droplist on the page based on a selection.
We have a service we are populating a Select droplist with. But we have another droplist on the page that, when the first droplist's section is made, the second droplist will dynamically populate with information based on the selection of the first droplist.
JSON structure example:
[{
"Cars":{
"Type": "Hatchback",
"Type": "Sedan"
},
"Trucks":{
"Type": "Small",
"Type": "Full Size"
}
}]
So if my first <select> droplist contains options for Cars and Trucks, then based on that selection the second <select>droplist will dynamically populate with the 'Type' based on the selection of a Car or Truck.
Does anyone have any insight or point me to any tutorials based on this?
Thanks in advance
Use the option in you first selection to populate the list:
<select ng-model="d1" ng-options="key for key in vehKeys"></select>
<select ng-model="d2" ng-options="t.Type for t in veh[d1]"></select>
my controller looks like this:(I changed your format, as it was, Type would just keep overwriting its self)
$scope.veh = {
"Cars":[
{"Type": "Hatchback"},
{"Type": "Sedan"}
],
"Trucks":[
{"Type": "Small"},
{"Type": "Full Size"}
]
};
$scope.vehKeys = Object.keys($scope.veh);
I'm not entirely sure why you cannot do something like this though
<select ng-model="d1" ng-options="type for type in Object.keys(veh)"></select>
so I just did it in the controller.
http://jsfiddle.net/valchev/s7ZCV/15/,
the above link is the simple example of Kendo grid with row template.All I wanted to do is make a specific column non-editable. the usual way is just define a model and further inside fields add editable False to the required field. i just wanted to know is there any other way to make a column editable as false because i dont want to add one more model in kendo as I am using models in entity level and Jay-data Level.
var dataSource = new kendo.data.DataSource({
data: records,
schema: {
model: {
id: "foo",
fields: {
foo: {type: "number"},
CostCategoryAbv: {type: "string",editable:false}, // i dont want this
VendorName: {type: "string"}
}
}
}
});
I've been doing a lot of work with the Kendo Grid using MVC. I've been getting around this by using a custom popup editor. The editor only allows the user to modify the fields that I want them to. Another way of getting around this is by changing the controller so that any user edit does not modify the field when the data source is updated. I know that the code provided is not using C# or MVC, but I hope this helps. I think you may be able to modify the save method so that it only saves select fields.