I'd appreciate if someone could advise on the following:
My Multiselect:
#Html.Kendo().MultiSelectFor(model => model.PAYMENT_METHOD).BindTo(paymentMethods).DataTextField("TITLE").DataValueField("CODE")
The dataSource looks like this:
CODE TITLE
1 abc
2 def
Is it possible to have composite DataTextField , specifically like: 1 - abc, 2 - def, etc., i.e "CODE" - "TITLE"?
I know I could create a select list and define the format of textfield, but maybe there is another way?
Thanks!
You could specify a template for the display item (you would probably want to take the text field out then):
#Html.Kendo().MultiSelectFor(model => model.PAYMENT_METHOD)
.BindTo(paymentMethods)
//.DataTextField("TITLE")
.DataValueField("CODE")
.ItemTemplate("#= CODE# #=' - '# #= TITLE#")
Here's the link to the ItemTemplate method and the link to the general template methods.
Related
I have an BelongsTo Fields like this:
BelongsTo::make( __( 'Parent Page' ), 'parent', 'App\Nova\Page' )->nullable(),
In the Dropdown is as a Default Value a Dash (—) and I would like to change this label to something like "Main-Page".
What I have now:
What I want to have
This is not possible using a BelongsTo field. The dash is hardcoded in the Vue component:
vendor/laravel/nova/resources/js/components/Form/BelongsToField.vue
<option value="" selected :disabled="!field.nullable">—</option>
This is used to create the first option in the select element.
Interestingly enough, it is possible using a Select field, which allows you to use the withMeta() function to set a placeholder. If you combine this with the selected meta value, you could create something like this:
Select::make('Parent Page')->options([
'Page 1',
'Page 2'
// ... etc
])->withMeta([
'placeholder' => 'Main-Page',
'value' => null // or any value you'd like to use to pre-select an option
])->nullable()
Note: this is done using Nova 2. I Haven't tried it with v1.
in db column having hash format title mobile description
i need to call these fields in a view page tags. how ? iam new to ror
step by step will be more helpful.
suppose your db column returns mobile_description so in controller you defined it ex-
#mobile_description = {:keyword => "Talek", :mobile => "789966558"}
and in view_page you can use these as tags where you want to show it like this ex -
mobile number #mobile_description[:mobile]
mobile title #mobile_description[:keyword]
My app has a pretty standard index page that lists all records in an ActiveRecord table.
I want to add a tooltip that provides some custom info when the mouse hovers over a row in the index page. However, my Google and Stackoverflow searches have yielded nothing on-target. (I suspect that if I were more familiar with ActiveAdmin and its components, I might have found the answer embedded in the documents I scanned.)
Can anybody provide me with the missing link? Thanks!
A colleague reminded me of the HTML4+ 'title' attribute, which actually displays a text-only tooltip when hovering on the element. Here is how I was able to implement it:
app/admin/some_models.rb
ActiveAdmin.register SomeModel do
...
index do
...
column some_field do |some_model|
div(title: 'tooltip text - can be a helper method call') do
some_model.some_field # the value to be displayed in the column
end
end
...
If a plain text tooltip is not sufficient, it would be necessary to add an onmouseover event listener to a style defined in the div or in the css defined for the div's class (class: must be specified in the div), then add a javascript function in app/assets/javascripts/active_admin.js or elsewhwere.
I hope this helps someone.
There are several options available here: http://www.unheap.com/section/user-interface/tool-tips/
You can do this in one line if you pass title as an optional argument to an attributes table row:
attributes_table do
row 'I am a row label', title: 'I am a tooltip', &:some_attribute_name
end
If your first (label) argument isn't a string or symbol, it will default to using the title argument as the label. You can read more about this in the ActiveAdmin source code for attributes_table.
I am trying to get a hook on a select and set the selected option. I am struggling to do this because my drop down is generated in a loop so the id changes.
Normally I would do something like this
select product_template.name, :from => "product_product_template_id
What if the ID can change
e.g. product_product_presentations_attributes_0_presentation_id
Is there a way to leverage the select function and specify a css selector?
Thanks.
select also accepts label (as in the actual <label> text for that select) and name attributes for the :from option, so if those are not generated / changed all the time, you can use them for a less brittle test.
If that doesn't cut it, you can add a unique CSS class to your select and then select a specific option with something like:
find("select.new_css_class").find("option[value='THE OPTION VALUE YOU WANT']").select_option
Using Yii 1.1.12. I have a CListView with ajax turned off:
<?php $this->widget('zii.widgets.CListView', array(
'dataProvider'=>$dataProvider,
'itemView'=>'_view',
'ajaxUpdate' => false,
)); ?>
The url for the link to the second page looks like:
http://www.example.com/products?Product_page=2
I want the url to look like:
http://www.example.com/products?page=2
How can I achieve this?
(A bonus would be to also describe how to get a url like http://www.example.com/products/page/2)
Update
As pointed out by elbek, I see the CListView has a pager property of type CLinkPager. This in turn has a pages property of type CPagination which has a property pageVar which is described as:
name of the GET variable storing the current page index. Defaults to
'page'.
Sounds like it could be what I'm looking for, not sure how to modify this from the CListView though.
Additionally to change the pageVar you have to modify the $dataProvider. You can do this when you are defining it in the controller action:
$dataProvider=new CActiveDataProvider('Products',array(
'pagination'=>array(
'pageVar'=>'page'
)
));
Alternatively you can of course modify the $dataProvider in the view itself before using it in the CListView : (not recommended-owing to separation of concerns)
$dataProvider->pagination=array('pageVar'=>'page');
$this->widget('zii.widgets.CListView', array(/*rest of your code*/));
But with this change, to make your url look like http://www.example.com/products/page/2 you'll need to slightly change the rule in urlManager from Suvera's answer:
'products/page/<page:\d+>'=>'products/index',
Note: If you don't need that type of url, you don't need the above rule, just specifying the pageVar does it.
enable the urlManager component on your config. And add the following rule at the top.
'urlManager'=>array(
......
'rules'=>array(
'products/page/<Product_page:\d+>'=>'products/index', //Add it in top
...........
...........
),
),
the above rule will create a url something like http://www.example.com/products/page/2
The value part in the rule products/index is products controller and index action (this is important, so point it out to your actual route).
you can even create urls whatever way you want.
ex 1:
'products/<Product_page:\d+>'=>'products/index'
will give you http://www.example.com/products/2
ex 2
'TheAvengers/vs/Loki/<Product_page:\d+>'=>'products/index'
will give you http://www.example.com/TheAvengers/vs/Loki/2
I think CListView has pager attribute(from its parent class)
You can try to set some attributes for this. I think it is CLinkPager instance.