Template field in ext js - extjs

I have the need to create the custom form field which need to works like TemplateColumn in gridPanel.
This custom form field will render multiple field in data model using the provided template just like TemplateColumn.
Since i only want to display data using this custom form field in the form panel so i try to extend the display field, but it only accept 1 data field in the model.
How could I make the custom form field accept value from 2 or more data field in model.
Thanks in advance.

you can bind to several fields and also included text
bind: {
value: "{rec.field1} - static text -> {rec.field2}"
}
feel free to add a fiddle to show what you want to do if this is not correct.

Related

Update form field value dynamically

I need to update the form field value using javascript as below:
var frmRec = App.frmEdit.getRecord();
frmRec.set('CallingName', 'Tesing calling name');
When I check the form data via the console, I can see the calling name field is updated:
console.log('rec: ', App.frmEdit.getRecord());
But the textfield in the form is not updated, old values still show up in the form. How can I "refresh" the value of the TextField in this case ?
Thanks in advance
If your data binding is setup correctly there is no need to refresh anything. The Extjs form supports two-way binding change to the record would be reflected in the text field and any change to the text field would be updated in the record.
two way binding example
The kitchen sink examples have lots of data binding examples.

ExtJs property grid - Selected rows editable?

I'm using a property grid with editors set in sourceConfig. I want only some rows to be editable and not all. Returning false in beforeedit disables all. The reason is, I have a button in a grid. When I click the button, the grid turns to a textfield! Any way to do this?
The beforeedit event should provide you with the editor and the editing context. Lets say your callback function looks like this:
function(editor,context) { ... }
Using the context you will get the record which get edited by accessing context.record while the editor can provide you with the editor form from where you have access to all rendered fields within that form. To get the form you have to get the editor first and after that you can fetch the form
var form = editor.getEditor().getForm()
This way you can be sure that the editor has been set up. To get a field within that form simply call
form.findField('fieldname') // fieldname is the dataIndex of the column
You can now do nearly anything based on your conditions.
In addition the record is also loaded into this form an can be accessed by calling form.getRecord()

How to make an extjs grid a form field?

I have a requirement to create a custom form field that is basically an extjs grid. The user should be able to click a result in the grid. This clicked result should then become the fields value. Also, this field needs to extend Ext.form.field. Here's what I got:
Ext.define('MyApp.field.Grid', {
alias: 'widget.GriedField',
extend: 'Ext.form.field.Base',
I'm a lot of confused on how to add a grid to form field base. Looks like form field base's template expects HTML. How do I get it accept a component?
If you just need to select a value from a list of items. Why not use a combobox?
If you need to select multiple items. There is an example of how to use the MultiSelect ux component in the documentation examples.
http://docs.sencha.com/ext-js/4-1/#!/example/multiselect/multiselect-demo.html
If you really must use a grid. Then I wouldn't bother with trying to create a field type and cause yourself grief.
Add a listener to your grids selectionchange event and update a hidden field in your form with the value you want from the grid. Job done.
I ended up putting the grid on a form indirectly through creation of dependencies on my model.
My model has master-detail, which the detail is just a store reference. I found that using associations did not work for me.
So, in adding a field to a form, I have something that manages changed events for the model (master record) and the detail stores.

Hide some of the field in GridEditMode.PopUp mode

I have Telerik MVC Grid which has popup edit form with several fields on of them is ID field.
.Editable(editing => editing.Mode(GridEditMode.PopUp))
I would like to hide ID field from popup edit form, how to do that?
You can create a view using *.ascx file , where you you will design the form as per the requirement and you can provide template name in .Editable as shown below
.Editable(editing => editing.Mode(GridEditMode.PopUp)
.TemplateName("MyView"))
Where MyView is a ascx file which holds the fields to be displayed.

Salesforce - Populate text are from drop down selection

I have a picklist with three values and a text area that has three values as well, but I would like to correlate one value from the picklist with one value of the text area. Any thoughts as on how I can do this?
If creating a visualforce page is an option, you can do this with a controller extension, or a custom controller. For example, you could override the save() method and have your new save code populate the text for you-- simply create a map of dropdown values to text area content and set the text as desired. It should also be possible to do this without saving by using some of the visualforce built in AJAX hooks: look at the onchange attribute. (Note that last I checked the onchange did not fire properly for lookups, but it may work for dropdowns)
Have a look at the visualforce documentation here: http://www.salesforce.com/us/developer/docs/pages/index.htm

Resources