I'm using ExtJS 3. I have a formPanel with many "cloned" fields and I gave every field the name "price[]". After submit I would like to loop through every field that has the name "price[]" and get their values one at a time to be checked against something in the database.
Note: there are other fields in this form so that's why I need to specify witch items to get from it, by name. I know how to submit the form, I just need to loop through those field and get their values.
How can I do this ?
Thank you!
You can use the find(propName, value) method of FormPanel. It returns an array of all the matches. The matches will be Ext.form.WhateverField objects, depending on what types of input elements your form has, and not raw DOM elements.
var priceFields = myFormPanel.find('name', 'price[]');
The BasicForm object has a property items: it is a mixed collection. You may iterate over the collection.
ExtJS forum
Related
I'm using react-hook-form useFieldArray. I have prepopulated the initial data which I got from API. I have almost 20 objects in an array. how can I know only which object data is changed.
Check formState.isDirty to see if the user changed any of the input fields, or formState.dirtyFields to get the specific fields changed by the user.
https://react-hook-form.com/api/useform/formstate
I've been searching for a while now and can't find any examples of how I could pass a custom value to a template I created with Schema Form. I needed to create a template to allow for the label to be aligned any way the user wants it to be. I got a simple version of the template working, now I need to give the template information like where the label should be aligned and how many columns the field should take so I can have multiple fields on a single row. I've tried passing my custom fields in the field definition and retrieving it in the template from the form object.
firstName = {
labelAlign: "left"
title: "First Name"
type: "string"
}
In the sample labelAlign is the custom field that I want to access through the form object and this is part of the data that is passed through the sf-schema directive. Is there another way I can access this data in my template?
Thanks in advance.
UPDATE
If I pass the custom value in the form JSON instead of the schema JSON the value show on the form but it creates another field at the very end of the form which is not what I am looking for. I've seen schema form examples that show modifying fields in the form JSON without having this problem. Does anyone know how to make this work properly?
I found the answer to my question and want to post it here for others. The object I was looking for was form.schema. That will allow access to properties created in the schema JSON.
I want to get the raw value of a numberfield by looking up its id. Here the raw value is 4 and the id of the numberfield is satirSayisi.
I have tried several combinations but non has worked.
grid.header.getById('satirSayisi').getRawValue()
Ext.getCmp('satirSayisi').getRawValue()
Your example is a little short on detail, but I think I've got the idea. You have a grid, and you want to 1) get the selection, 2) get the model from this selection so that you can 3) get the value of a number field (satirSayisi). I'm assuming satirSayisi is the column name in the model, and not necessarily the id or itemId property.
Assuming that you have a handle on the grid, you grab a model from the selection like so:
var model = grid.getSelectionModel().getSelection();
Now you have a model instance (which should correspond to your database columns in some way). To get the value from satirSayisi, you would say:
var stuff = model.get('satirSayisi');
Accessing components by Id in ExtJS is no longer recommended. They suggest the use of itemId over id. A better way to get access to an object is ComponentQuery, such as...
component = Ext.ComponentQuery.query('button#Save')[0];
This example will give you a handle on the first button type object in your application with the itemId of Save. It will always grab stuff in an array, even when there is just one result.
Good luck!
i am new struts i am developing web application in which i have a requirement that i have to show records in tabular format i have made use of display tag in struts with every record i have a checkbox now i need to retrieve the values of those checkboxes in my Action which are checked . but what i am receiving in Action array of all the checkboxes. actually while displaying checkboxes by making use of display tag all checkbobes have got same name therefore i am not understanding how handle this care i have searched on google but did not find suitable situation
<display:column title="Service">
<input type="checkbox" name="sercive" />
</display:column>
how to handle this situation not understanding .could anyone give some sample code
or hint to handle this situation
I am not sure about display tag.
But in struts you have to define a property in Form bean (i.e. ActionForm) of type String[] or List with the name same as defined for your check boxes.
Then in Action class you will get the array of selected checkboxes only.
If this is not working. Then you can try of getting the values using request.getParameter("service"). This will return comma separated list of selected checkboxes which you can convert to array using split() method and then you can continue with your logic.
I hope this helps you.
Plain HTML checkboxes are only submitted if they're checked, that's just how clients work.
You must provide a differentiating factor, generally a value (e.g., a service ID in your case), to determine which has been selected. Your action form would contain a collection of those IDs.
I would like to assign input fields in a view types from a custom array, not from a model, as Cake usually does.
So, I have in my array (passed to the view) a key which tells the field type the field in the database must have:
[type] => 'varchar(32)'
I would like Cake to know this field type and automagically assign it to the corresponding input field (so that, for the example above, the input will be a text). How can I achieve this?
Thank you.
P.S.: These are the 'transformations' I would like to achieve (from the table): Data types correspondings in Cake
linkyndy,
The mapping from model schema types to html form elements is done here - http://api.cakephp.org/view_source/form-helper/#l-738. Furthermore, varchar(32) (string) will create an html input element when using the FormHelper. Is it you want a textarea instead?
If you do not want to use the automatic field detection you can specify the element type in your call to input. If that's not acceptable, you can change your db field types to meet what CakePHP expects... or manipulate your model's schema() results... or provide your own helper with an overridden input() method.
Specifying the type in calls to $this->Form->input() seems easy enough.