How to rename context menu items in handsontable.js? - javascript

I satisfy with copy option in contextmenu of hansontable but my users would like to see translated name for this item('копировать'). Is any simple way to rename a contextmenu item in handsontable?

In order to rename the items in your context menu, you need to customize it as described in the documentation.
Following their example, you need to use the parameter 'name' of the "copy" item :
hot3.updateSettings({
contextMenu: {
items: {
"copy": {name: 'копировать'},
}
}
})
You cand find an example here.

Related

How to add sort to bootstrap-table card view / custom view?

I am trying to create a sort to be used directly from the card mode (custom mode in my case).
I created the button myself but I can't find a method to call sort on a field when not in table view.
Like the option to filter, I am looking for something like:
$("#bootstrapTable").bootstrapTable("sortBy", {
sortAlgorithm: sorter }
For example here:
If you switch to table view (click the eye), you can sort by name by pressing on the table header.
But then on card/custom view, you can't.
How can I make the button there to sort by name?
I found a way to solve this.
You can use $('#table').bootstrapTable("refreshOptions", {}) to change the sort options and it will take effect.
In the above example you can use:
<button onclick="sorter()">
Sort by name
</button>
<script>
function sorter() {
console.log("here")
$("#table").bootstrapTable("refreshOptions", {
sortName: "name",
sortOrder: "desc",
});
}
</script>
of course, you can modify it to sort on whichever column you want and change the order.
Hope it helps whoever stumbles here on the future

How do I add a custom Help menu to TinyMCE4?

I am using a custom menu for TinyMCE4. In the initialization call, my menu setup looks like this:
menu : {
... <other menu sections>
help: { title: 'Help', items: 'help' }
},
I was expecting this to yield the following, which is what you get by default or when the Help item is in the menubar property (blue highlighting is mine):
Instead I get nothing.
How can I manually include the help menu?
EDIT : This defect was fixed in TinyMCE 4.7.8 so its no longer correct to name the item 'Help' - you should use 'help' from 4.7.8 onward.
Due to a defect in TinyMCE you need to use this code:
help: {
title: 'Help',
items: 'Help'
}
...note the items value starts with H not h. Here is a working example:
http://fiddle.tinymce.com/Nkgaab/1
The incorrect need to use Help will be fixed in a future TinyMCE release at which point you will need to modify the configuration to use help.

Search for an item in MixedCollection

I use Ext JS, so
I have a toolbar with items (buttons, labels etc). I add elements to the toolbar like this :
toolbar.add(this.tempObject);
or like this:
toolbar.add({
xtype: button,
...
});
So, I want to find some elements in this toolbar by field "ref". I tried to:
toolbar.items.find(new Function("there should be my function, but i have no idea how to write it"));
And there is no promice that every element in this collection will have this field.
Use the findBy method:
toolbar.items.findBy(c => c.ref == 'the value you want');
There are other methods for talking about child items on containers, however it depends on the Ext version and what you're looking for.

ExtJS: add new MenuItem to Menu instance at runtime

I need to add a newly-created MenuItem at runtime; so my code currently looks like:
var myMenu = myCmp.query('mymenu')[0]; // retrieve my only Menu object
var menuItem = Ext.create('Ext.menu.Item', {
itemId: 'myItemId', text: 'textGoesHere'
});
myMenu.add(menuItem);
I'm using the add method to add the item; but nothing happens to the menu items though at run-time. Even though debugging shows that the new item has actually been added to the items config of the Menu instance.
Using the remove method however does work, at run-time.
Question: How to make the newly added MenuItem show at runtime? What am I missing?
UPDATE: the above code works; I had a flawed switch statement that was causing another pass through the logic, removing the last created menuItem.
Comment bump up
The OP wrote
OK I track the issue down; I had a flawed switch statement that was
causing another pass through the logic, removing the last created
menuItem. Still I'll mark your answer as correct as it works as well
(by passing the config obj).
This example works:
var menu = Ext.create('Ext.menu.Menu', {
width: 100,
height: 100,
floating: false, // usually you want this set to True (default)
renderTo: Ext.getBody(), // usually rendered by it's containing component
items: [{
text: 'icon item',
iconCls: 'add16'
},{
text: 'text item'
},{
text: 'plain item',
plain: true
}]
});
menu.add({text:'test'});
I am not quite sure but according to the API the Menu has panel as default type when you look at the menu but it seems to be menuitem according to the menuitem API This might be a little confusing.

Extjs 4.02 - Custom component needed

I am trying to create a custom container but can't figure just how to do it.
I need it to look like this:
(don't pay attention that it is RTL, this is only a sketch to get started)
where the orange fonts are the title of the page that I would like to be an H1 element.
It has a simple search and an advance search that pops open when the little arrow next to the search button is clicked.
Questions:
1) What should I extend for that ?
2) How can I implement different advance search forms for different pages ?
3) how can I place a setter for the title that controllers can interact with and manipulate the dom ?
basically any advice will be good as I need a start point.
thanks
There are lots of ways of doing this, but this is what I would do.
I'm not sure about the "advanced forms for different pages" can you go into mre detail about that? Are you looking to autogenerate a search form somehow?
Extend Ext.form.Panel, and use a table layout for the fields
See: http://docs.sencha.com/ext-js/4-0/#!/api/Ext.layout.container.Table
use a "tbar" on the panel instead of setting "title". you can place the search combo, tbfill, then a tbtext for the "title". As a convenience you can override the setTitle function of the panel to manipulate this tbtext field instead of the normal behavior. Something like this:
Ext.define('MyApp.view.MyForm', {
extend: 'Ext.form.Panel',
alias:'widget.myform',
layout:{
type: 'table',
columns: 4,
tableAttrs: {
style: {
width: '100%'
}
}
},
//overridden setTitle
setTitle:function(title){
Ext.getCmp(this.id + "_search_combo").setText(title)
},
defaults:{
xtype:"combo",
//rest of combo config here
},
items:[{
//...
}],
initComponent:function(config){
this.tbar = tbar:[{
xtype:"combo",
//...
id:this.id + "_search_combo"
},{
xtype:"tbfill"
},{
xtype:"tbText",
cls:"my_form_title",
value:this.title||""
}]
//prevent default title behavior
delete this.title
this.callParent(arguments);
}
})
I would suggest you to just extend from Ext.panel.Panel itself, and hijack the dom for all those customized items, add in search bar, etc. If you do not want any of the fancy stuff from Ext.panel.Panel, you can also extend it from Ext.Component, or Ext.container.Container (to contains more components), and even the lowest Ext.util.Observable.
It seems like you might need to extend a few Ext.menu.Menu and defines some different set of input boxes, so that you could benefit from creating a floated menu (if that's what you want). Or if you have time, you can even just extend from Ext.Component and build your own customized component, or even lower, Ext.util.Observable.
The setter? It will be in the extended component in (1) then :)
All of these serve as rough opinions. They could be different depends on your requirement.

Categories

Resources