Field Validation in EditorGrid - gxt

Let's start with saying that I'm using GXT 2.2.5 on GWT 2.3.0.
My goal is to present the user with a set of data retrieved from a query where he needs to specify a value for one of the fields. As an example, let's say the query returns a list of phone numbers, and the user needs to sepcify the type of number (i.e., Home, Office, Cell, or Pager) each is.
So I'm looking at the EditorGrid as a potential solution. The grid would display the type and number, with a ComboBox attached to the first field through a CellEditor.
The requirement is that the user must select a type for each number. How do I enforce this? I can set allowBlank to false on the ComboBox, but how do I manage it? How do I validate the grid?
I've searched for an answer, but have been unsuccessful.

I suggest the use of the Grid, not the EditorGrid. When using a RowEditor within the Grid the allowBlank validation (or any other fields validator) are fired when the user saves row changes.
Here is a little example in case you are not familiar with the Grid:
ColumnConfig colNombre = new ColumnConfig("name", "Name", 200);
TextField<String> txtNombre = new TextField<String>();
txtNombre.setAllowBlank(false);
txtNombre.getMessages().setBlankText("IT CANT BE EMPTY.");
colNombre.setEditor(new CellEditor(txtNombre));
configs.add(colNombre);
re = new RowEditor<BeanModel>();
re.addListener(Events.AfterEdit, new Listener<RowEditorEvent>() {
public void handleEvent(RowEditorEvent e) {
editar(e);
}
});
re.setClicksToEdit(ClicksToEdit.TWO);
grid = new Grid<BeanModel>(STORE, new ColumnModel(configs));
grid.addPlugin(re);
hope it helps.

Have a SimpleComboBox<String> to store all types of numbers (Home, Office etc). Attach it to the EditorGrid. Set the setEditable(false) property for SimpleComboBox<String>, and make sure that a valid "type" is selected by default in the combo-box (using setValue(...)).
In this way, when your Grid gets rendered, the phone numbers will have type beside them, having a default value selected.
I feel that this is a good approach, rather than having combobox with blank value initially, and then asking user to fill it by showing validation error.

Related

Two Combo Boxes in Xpages determining the Value of other Computed fields using #DbLookup

I have a form that has several fields that update based on combo boxes. The first combo box uses #DbColumn to pull the first column in a view. The second combo box pulls the second column in the same view based on the the selection of the first combo box. That works fine. The issue is; I have several succeeding computed fields that use the selection from the second combo box to pull from the same view's, succeeding columns. Those computed fields are not working. I thought I could merely use an #DbLookup command in Javascript to call the values from the view but it is not working.
Here is the javascript code for the first combo box (pretty simple):
#DbColumn(#DbName(), "PLBV", 1)
Here is the second combo box code:
var vendor = getComponent("POVendor").getValue();
var items = #DbLookup(#DbName(), "PLBV", vendor, 2);
if (#IsError(items))
return "Please select a Vendor first";
else
return items;
Both of these routines work exactly as I want. Here is the issue. I have three more fields that should be populated based on the value of the second combobox. It doesn't work. I'll give you the code but it's really basic.
var item = document1.getItemValue("Item_1");
var cost = #DbLookup(#DbName(), "PLBV", item, 3);
return cost;
This code returns a blank value (nothing shows up in the field). What am I doing wrong?
If you are trying to access the item before the document has been saved then you will need to use the following code:
var item = getComponent("Item_1").getValue();
var cost = #DbLookup(#DbName(), "PLBV", item, 3);
You might need to use getSubmittedValue() rather than getValue() depending upon the validation settings of the document.
Hope this helps.
Matt
The problem stemed from me trying to call the value of a column from the same view I populated the second combo Box. That view has the first column categorized by the Vendor Name. The second column (the column I used to populate the second combo box) was a list of products offered by that vendor. That part worked fine. However; when I tried to call the value of the third columnm from the same view based on the value of the second combo box (the product), I got nothing.
I have a separate view that is a complete list of products without being categorized by the vendor that offers the product. I called colunms from that view based on the product name from the second combo box & all of my computed fields worked. Now my only issue is going to be, what happens when two different vendors use the same product name for two different products? I'll cross that bridge when I come to it. Thanks for all the help from everyone. It may not have solved the surfase issue but it gave me a much more in-depth understanding of what goes on behind the scenes.

Getting data from a datasource with Filter by Column Value?

I have a list box where I am trying to get the datafrom the people view in names.nsf.
The first column of the people view is computed and shows Last Name , First Name.
The code below works fine for my list box values but it does not take into consideration the value in the Filter By Column Value. Basiclly the code below acts like the Filter By Column value property does not exist. I know the Filter by Column value property is working because I replaced a repeat control on the page with a computed field and the repeat control is displaying the value excepected but the list box is displaying values from the first document in the view.
Thoughts I had to fix this are:
Use getAllDocumentsByKey to just search the people view but when I do that I lose the column values and I would need to recompute the value, something that I would like to avoid if possible incase the column formula changes.
Use FTSearch but what I really need to do is search that first column only and I am not aware of search operator that searchs a column only. Is there such a thing?
Another thought would be to somehow use the values of a repeat control, as the values for my list box, but I am guessing that this is not possible. I sort of thinking something with a scope varibale but I have not worked that out yet.
A repeat control works. How can I get my code to loop through the doeuments the same way a repeat control does?
And as a side question, is there anyway to tie a pager to a datasource as oppsed to a repeat control.
BTW What I currently do is to build a list box using a few computed fields and a repeat control but what I really want to do is to use a regular xpages list box control.
Here is the code:
var doc:NotesDocument = view1.getFirstDocument();
while (doc != null && count<10)
{
var tmpDoc:NotesDocument = view1.getNextDocument(doc)
ret.push(doc.getColumnValues()[1]);
doc.recycle();
count++;
doc = tmpDoc;
}
Try to use getAllEntriesByKey. This will give You access to column values (through ColumnValue property of view entry).

Dynamic Layouts in Filemaker

First off I am new to FM but I have a good handle on the basics. What I need to do is this - in a contact information type layout I want to be able to alter the layout based on a specific field. Ex. When the record is brought up, the background of the layout will change colors for a client, another for vendor, etc.
I tried to change a label based on a field, with no success. My guess is that the layout is static and only the data fields change.
We use FM Pro.
Thanks,
Mark
FileMaker layouts are static, but there are still some things you can do to alter the layout based on the values of fields:
Calculation Fields
If you want the data shown in an area to change, you can use a Calculation field. A typical example of this would be a status field. To do this you would add a new field to your table and use enter a calculation on that field like:
Case (
IsEmpty(myTable::myField) ; "Please enter a value for myField." ;
myTable::myField = "wrong value" ; "Please enter a correct value for myField." ;
"Everything seems okay."
)
Conditional Formatting
To make things like background color change you can use a conditionally formatted field. I will typically add an empty numeric field (for this example we'll call it emptyField) and set it so that it can't be edited during modification.
If you place emptyField on your layout, below all the other fields and disallow the user to enter the field in either Browse or Find mode, you can then use conditional formatting to change the field's color.
Portal Hiding
You can use this technique when you want some elements of your UI to disappear when they aren't needed. For example, if you want a "submit" button to appear only when all of the records on a field are filled out.
To use this technique I will usually create a Calculated number field, called ReadyForSubmit, on the original table and give it a logical calculation like:
not IsEmpty(field1) and ... and not IsEmpty(fieldN)
(Note that the value of the above function would be 1 or 0)
I will then create a new Support table in my database and add to it a field One with a calculated value set to 1.
I will then make a relationship between myTable::readyForSubmit and Support::One.
On the layout, create a portal with one row. Put your Submit button in that layout. Now, when readyForSubmit calculates to 1 the button will appear. When it calculates to 0 the button will be hidden.
Hidden Tab Browser
Finally, you can use a tab browser where you set the title font size to 1 point, hide the border, and control the browser programmatically. You can use this for having different field arrangements for different types of records. To do this you would first give an Object name to each tab of the tab browser, say Tab1, Tab2, Tab3.
Then you would add a script, goToTab, with the logic for when you want to go to each tab. Say:
If (myTable::myField = "corn")
Go to Object (Tab1)
Else If (myTable::myField = "squash")
Go To Object (Tab2)
End If
You would then use Script Triggers to run goToTab when On Record Load.
With the release of filemaker 13 there may be another way to do this. You could use a slide control, name the panels in the control, and conditionally switch to the correct panel based on the record type.
you would drop the appropriate fields for the record type in each panel.
http://help.filemaker.com/app/answers/detail/a_id/12012/~/using-slide-controls-and-slide-panels-in-filemaker-pro

jqGrid Filtering Records

It seems there have been a few questions here regarding this subject, and they have some great answers, but it seems that my case is a little different. I need to filter the records displayed in a jqGrid, but entirely client-side.
For a number of reasons, the best way for me to populate my grid is with an array that's emitted directly into the JavaScript on the page. The grid itself doesn't interact with the server at all. I have some custom AJAX happening in various grid events, but that's it. (Basically, I'm integrating this with an existing set of available services which can't change significantly.)
What I'm looking to do is filter the grid based on a simple text input and button. My page has the text input, the button, and a table (which becomes the grid on document ready). I'd like to bind to the click event of the button (normal jQuery event binding, nothing special) and use the value from the text input as a display filter on the jqGrid.
By "filter" I mean to display only the records which contain a match (in any field) for the text in the input. Then, to display all records, just empty the input and click the button again. Additionally, the grid is multi-select and the selections need to persist through filtering. I just need to be able to hide the rows which don't match what's in the input.
Is this possible?
To filter local grid you should only fill filters property of the postData parameter of jqGrid and set additionally search:true.
To save selection of the grid you can use reloadGrid with additional parameter [{page:1,current:true}] (see here).
The corresponding code can be the following
$("#search").click(function() {
var searchFiler = $("#filter").val(), grid = $("#list"), f;
if (searchFiler.length === 0) {
grid[0].p.search = false;
$.extend(grid[0].p.postData,{filters:""});
}
f = {groupOp:"OR",rules:[]};
f.rules.push({field:"name",op:"cn",data:searchFiler});
f.rules.push({field:"note",op:"cn",data:searchFiler});
grid[0].p.search = true;
$.extend(grid[0].p.postData,{filters:JSON.stringify(f)});
grid.trigger("reloadGrid",[{page:1,current:true}]);
});
I made the demo for you which filter for two columns 'Client' ('name') and 'Notes' ('note') you can extend the code to search in all columns which you need.
Depend on what you exactly mean with the saving row selection you can need to save the current selection from the selarrrow in a variable and restore the selected rows with respect of setSelection method.

Fill textbox with current username logged in sharepoint

I made a custom list, it is actually a form fill out for an absence request workflow. Before publishing it I found a flaw.
The first textbox is a Person or Group textbox, this helps out to retrieve the Active Directory username, but the flaw is that I can type whatever username I want, Example:
"User X is logged on, but if he types User Y and hits enter he can request an absence for User Y"
So what I want is, hide the textbox and fill it automatically with the current logged on user.
I've been looking for formulas for the calculated textboxes but I haven't found anything.
I´m not exacly sure what you wan´t to do here but if you have a peoplepicker that you want to fill with the current user, here is how to do that. Then you would have to disable the control in order for the user not to be able to change the value in it.
PickerEntity entity = new PickerEntity
{
Key = SPContext.Current.Web.CurrentUser.LoginName
};
PeopleEditor.Entities.Add(entity);
PeopleEditor.UpdateEntities(PeopleEditor.Entities);
Does this help?
SPUser user = SPContext.Current.Web.CurrentUser;
If you want the current logged in user, just use the Created By field in the list. This column is automatically populated with the user who created the item.
Try SharePoint Designer WF that takes Created By and sticks it in that field.
Or, hide the column using jQuery and just have it populate by using the default value of the field as [ME]. [ME] fills in the textbox with the currently logged in user.
Edit: This whole thing could be dealt with by just grabbing the Created By in the workflow. You don't even need to capture the value in a textbox. SharePoint knows who created the item already. This will actually result in a less complicated form.

Resources