Quantcast
Channel: SmartClient Forums
Viewing all 4756 articles
Browse latest View live

Does TreeGrid.setCriteria() support advanced criteria?

$
0
0
Does TreeGrid.setCriteria() support advanced criteria? I have tried modifying example

http://smartclient.com/#_Trees_Filtering

and replace simple criteria
Code:

{EmployeeType: 'full time'}
with
Code:

{'_constructor': 'AdvancedCriteria', 'operator': 'and', 'criteria': [
        {'operator': 'iContains', 'fieldName': 'EmployeeType', 'value': 'full time'}
]}

However the TreeGrid seems to ignore it (does not apply at all).

If advanced criteria is not supported, is there a way to specify "contains" match type for simple criteria?
Thank you.

Filter Like '%'

$
0
0
Hi,

I've got a ListGrid with the properties linked to a CustomDataSource

showFilterEditor=true
filterOnKeypress=true

From what I see the filter has a LIKE '%XXX%' behavior. I was wondering if is possible to change this default behavior to 'XXX%' for all the columns in the ListGrid

My ListGrid is as follows.

Code:

isc.ListGrid.create({
                            ID: "scheduleList",
                                top: "8%", left: "17%",
                                width:"83%", height:"91.9%",
                            dataSource: batcherScheduleDS,
                            alternateRecordStyles:true,
                            autoFetchData: true,
                            showFilterEditor: true,
                            canEdit: true,
                            editEvent: "click",
                                editByCell: true,
                            canRemoveRecords: true,
                            border: "1px solid light grey",
                            filterOnKeypress: true,
                            click:"setScheduleFormDetails();",
                            warnOnRemoval:true,
                            filterOnKeypress: true,
                           
                            removeRecordClick: function ()
                            {
                                    preRemoveSchedule();
                            },
                                warnOnRemovalMessage:"Remove this Schedule?",
                               
                        });

Uplload file and custom server implementation .net

$
0
0
Hi,

I am using SmartClient v9.0 I need to perform a file uploading.

On client side I have the follwing code:
formItems = [



{ name: "item1", type: "header", defaultValue: "Regarding Info" },
//----- data items -----\\
{ name: "RegardingType", title: "Type", type: "text", defaultValue: "Protocol", width: 300, canEdit: false },
{ name: "RegardingObject", title: "Object", type: "text", defaultValue: "prtcll 001", width: 300, canEdit: false },

{ name: "Name", title: "Name", type: "text", defaultValue: "", width: 300 },
{ name: "File", title: "File", type: "upload", width: 300 },
{
title: "Upload",
type: "button",
click: function () {
formEdit.saveData();
}

}

isc.Window.create({
ID: "modalWindow",
title: "Document",
autoSize: true,
autoCenter: true,
isModal: true,
showModalMask: true,
autoDraw: false,
items: [
isc.DynamicForm.create({
ID: "formEdit",
dataSource: mediaLibrary,
autoDraw: false,
left: 5,
top: 10,
width: 350,
padding: 4,
fields: formItems
})
]

});


I could select the file.

On server Side i have a Generic ASP.net Handler in the processRequest method i can read the parameters on requestBody
{"RegardingType":"Protocol","RegardingObject":"prt cll 001","Name":"Test","File":"C:\\Users\\pb00125\\Des ktop\\WNODKServiceModule\\appunti.txt"}

the file contains the File path, but how to get the uploaded file?

Thanks,

Inquiry : PDF

$
0
0
1. Smart GWT Version 3.0
2. Browser: IE 9
3 Server Side: Spring 3.x & HIbernate

Inquiry:

In our project, we use a servlet to show PDF(we use Itext to generate PDF Document) ..We have issues of 'overlapping content' once in a while as this is not thread safe ... Leaving all that aside.. we are trying to figure out a way to have the pdf all with in the app in sepeparte window.

All of our AJAXcalls uses GWT-RPC machanism to get the server side information.
With out many changes, we could get the get Document(content )back to the UI... Basically, we have Byte Stream here available..
My question here is : Is there a way that we can write/flush this byte stream onto layout/widget/window ?

customSQL: select into outfile

$
0
0
Hi,

We have been using SmartGWT and customSQL for a while. We wonder if it is possible to write a customSQL that actually use the "SELECT ... INTO OUTFILE" syntax?

We have the datasource descriptor like this but so far could not get it to work. We test the query itself and it did run if we invoke it from a MySQL GUI (MySQL Workbench). We checked the MySQL process on the server do have the write permission to write file into the target path. We also check that the MySQL use has the FILE permission.

Code:

<operationBinding operationType="fetch" operationId="RsSelectIntoOutfile" sqlType="update" >
    <customSQL><![CDATA[
        select *
        into outfile '/var/run/aware/nara/resultSets/rs313089401.csv'
        fields terminated by ',' optionally enclosed by '*'
        lines terminated by '\n'
        from nara_db.rs313089401
    ]]></customSQL>
</operationBinding>

ListGrid removeSelectedData calling Delete method multiple times

$
0
0
Hi

We are trying to remove a record from the ListGrid using the
Code:

listGrid.removeSelectedData();
and also used another way
Code:

                ListGridRecord userRecord = listGrid.getSelectedRecord();
               
                ListGridRecord[] userRecords = listGrid.getSelectedRecords();
               
                for (ListGridRecord listGridRecord : userRecords) {

                    Map<String, String> params = new HashMap<String, String>();
                    params.put("_wsId", (String) SessionCtxt.getInstance().getCurrentWsId());
                    params.put("_removeWsRecord", "true");
                    params.put("_sessionId", SessionCtxt.getInstance().getId());
                    params.put("_id", userRecord.getAttribute("_id"));
                    DSRequest requestProperties = new DSRequest();
                    requestProperties.setData(params);
                   
                    listGrid.removeSelectedData(new DSCallback() {
                               
                                @Override
                                public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
//                                        if (dsResponse.getStatus() == RPCResponse.STATUS_SUCCESS) {
                                                fetchData();
//                                        }
                                       
                                }
                        }, requestProperties);                       
                }

The way we do it is we call a REST API to delete the record when removeSelectedData is called
If we select only one record then the record gets deleted fine and the listGrid also updates correctly.
But when we select 2 records it calls the REST API twice and if we select 3 records it calls the REST Call 3 times and so on.
and in all the cases the first call is correct and sends SUCCESS back but as number of calls are done after that it throws errors

We want to restrict the call of removeSelectedData just once
Sending you all the required parameters with this

Version: 4.0-p20130904
Browser: All browser IE, Chrome and firefox

Am I doing this the "Smart"GWT way? (inter widget hover dependencies and CSS styling)

$
0
0
Hi Iso team,

I have created a "composite widget" consisting of a Canvas and a MenuButton in order to implement FontAwesome icons in a RibbonBar without losing the functionality that a MenuButton provides. The Canvas holds the Font Icon (via a simple CSS class set), and the MenuButton is simply text.

However, I need both widgets to look like they are one. So when you hover over one, it looks like you're hovering over both.

Because the Canvas object needs to always hold style "fa-xxx" for the FontAwesome icon, I can't use StatefulCanvas unless I muck with the FontAwesome CSS, which creates future compatibility issues with FontAwesome.

I also don't want to fire a MouseOver event on one while hovering over the other, and visa versa, because that would create a circular reference.

So I chose to update the styles upon MouseOver, letting the MenuButton, which is a type of StatefulCanvas self-manage whenever possible.

It's working well, but it does mean I'm self-managing CSS of the MenuButton whenever hovering over the Canvas/Icon. Tell me if you have a best practice or better way for getting this done?

Code:

import com.smartgwt.client.types.Alignment;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.types.VerticalAlignment;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.events.HoverEvent;
import com.smartgwt.client.widgets.events.HoverHandler;
import com.smartgwt.client.widgets.events.MouseOutEvent;
import com.smartgwt.client.widgets.events.MouseOutHandler;
import com.smartgwt.client.widgets.events.MouseOverEvent;
import com.smartgwt.client.widgets.events.MouseOverHandler;
import com.smartgwt.client.widgets.layout.VLayout;
import com.smartgwt.client.widgets.menu.Menu;
import com.smartgwt.client.widgets.menu.MenuButton;


/**
 * Special Layout that combines a FontAwesome icon, optional title/text, and is capable of opening a Menu
 *
 */
public class RibbonButton extends VLayout
{
  private Canvas icon;
  private final String iconCSSName;
  private MenuButton menuButton;
  private Menu menu;
 
  private final String CSS_NAME = "ribbonMenuButton";
  private final String CSS_HOVER_NAME = CSS_NAME + "Over";
 
 
  public RibbonButton(final String iconCSSName, int iconWidth)
  {
    this(iconCSSName, iconWidth, null, null);
  }
 
  public RibbonButton(final String iconCSSName, int iconWidth, String menuTitle)
  {
    this(iconCSSName, iconWidth, menuTitle, null);
  }
 
  public RibbonButton(final String iconCSSName, int iconWidth, String menuTitle, Menu menu)
  {
    super();
   
    this.iconCSSName = iconCSSName;
    init(menuTitle, menu);
    arrangeComponents(iconWidth);
  }
 
 
  private void init(String menuTitle, Menu menu)
  {
    icon = new Canvas();
    menuButton = new MenuButton();

    setMenuTitle(menuTitle);
    setMenu(menu);
  }
 
 
  private void arrangeComponents(int iconWidth)
  {
    setStyleName("ribbonButtonWrapper");
    setWidth(48);
    setHeight(42); //6px higher than icon + menuButton because of 6px top margin in cv_etl.scss
    setAlign(Alignment.CENTER);
    setLayoutAlign(Alignment.CENTER);
   
    icon.setWidth(iconWidth);  //for Font icons has to be done before attaching - also closely aligned to the font-size of the icon in cv_etl.scss
    icon.setHeight(20);
    icon.setOverflow(Overflow.HIDDEN);
    icon.setLayoutAlign(Alignment.CENTER);
    icon.setLayoutAlign(VerticalAlignment.CENTER);
    icon.setAlign(Alignment.CENTER);
    icon.setStyleName(iconCSSName);
    icon.setCanHover(true); //default Canvas objects do not have this set (aka null/false)
   
    icon.addMouseOverHandler(new MouseOverHandler()
    {
      @Override
      public void onMouseOver(MouseOverEvent event)
      {
        icon.setStyleName(iconCSSName + " " + CSS_HOVER_NAME);
        menuButton.setStyleName(CSS_HOVER_NAME);  //momentarily override base style
      }
    });
   
    icon.addMouseOutHandler(new MouseOutHandler()
    {
      @Override
      public void onMouseOut(MouseOutEvent event)
      {
        icon.setStyleName(iconCSSName);
        menuButton.setStyleName(CSS_NAME); //back to "base style" so its own hover works
      }
    });
   
    menuButton.setBaseStyle(CSS_NAME);
    menuButton.setWidth(48);
    menuButton.setHeight(16);
    menuButton.setLayoutAlign(Alignment.CENTER);
    menuButton.setLayoutAlign(VerticalAlignment.CENTER);
    menuButton.setAlign(Alignment.CENTER);
   
    menuButton.addMouseOverHandler(new MouseOverHandler()
    {
      @Override
      public void onMouseOver(MouseOverEvent event)
      {
        //menu button handles hover automatically - only apply hover style to custom icon here
        icon.setStyleName(iconCSSName + " " + CSS_HOVER_NAME);
      }
    });
   
    menuButton.addMouseOutHandler(new MouseOutHandler()
    {
      @Override
      public void onMouseOut(MouseOutEvent event)
      {
        //menu button handles hover automatically - only apply hover style to custom icon here
        icon.setStyleName(iconCSSName);
      }
    });
   
    addMember(icon);
    addMember(menuButton);
  }
 
  public void setMenuTitle(String menuTitle)
  {
    menuButton.setTitle(menuTitle);
  }

  public void setMenu(Menu menu)
  {
    menuButton.setMenu(menu);
  }
 
}

Thanks!
-Becky

getAttributeAsBoolean with null values

$
0
0
In SmartGWT 4.0, I'm trying to load a hibernate-backed entity into a ListGridRecord and then back to the entity.

The entity contains a few optional true/false values, represented as java.lang.Boolean objects with true/false for set values and null for no value provided.

Unfortunately, when I try to convert this into a record and back again (setAttribute/getAttributeAsBoolean), the null is being converted into a false.

It looks like this is happening in the JSOHelper class. Most of the getAttribute calls allow for a null by returning the null object, but JSOHelper.getAttributeAsBoolean is explicitly converting that null into false to return the primitive value instead of the wrapper class.

Is this intended behavior? If so, is there another way I should be accessing a Boolean value?

Scroll bar issue

$
0
0
Hi,

While manually increasing List grid column width of 2-3 columns the horizontal scroll bar added to container of List Grid rather then ListGrid. Due to this issue, the UI look and feel changes.

The behavior seen after upgrading to isomorphic 9.x.

Please let me know why it's behavior changed and how to fix it.

I am using :

SmartClient Version: v9.0p_2013-08-16/Enterprise Development Only (built 2013-08-16)

Browser : Firefox (version - 25.0.1)

Thanks !!!

How to resolve [WARNING] Forked JVM has been killed on time-out after 1800 seconds

$
0
0
After running several days nightly build of our smartgwt project, sometimes there will have a JVM killed issue caused by time out. If we restart our linux server, the issue will be resolved, but after serveral days nightly build, it will come up again.

Could you please help me to resolve this issue. Really appreciate for your suggestion on this.

1. Version
<gwt.version>2.5.1</gwt.version>
<gwt-maven-plugin.version>2.5.1</gwt-maven-plugin.version>
<smartgwt.version>4.0</smartgwt.version>

2. Pom fragment
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-maven-plugin.version}</version>
<configuration>
<module>com.fusion.platform.gui.${env}</module>
<includes>**/GuiGwtTestSuite.java</includes>
<timeOut>1800</timeOut>
<testTimeOut>1800</testTimeOut>
<mode>htmlunit</mode>
<extraJvmArgs>-Xmx1024m -Xms1024m -Xss1024k</extraJvmArgs>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

3. Build failed info
[INFO] Compiling module com.fusion.platform.gui.PlatformGui
[INFO] Validating units:
[INFO] Ignored 258 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO] Compiling 6 permutations
[INFO] Compiling permutation 0...
[INFO] Compiling permutation 3...
[INFO] Compiling permutation 4...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 2...
[INFO] Compiling permutation 5...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 1...
Process 1387262362712 is killed.
[WARNING] Forked JVM has been killed on time-out after 1800 seconds
[INFO]

How to resolve SecurityException: Could not lock User prefs.Lock file access denied.

$
0
0
Sometimes our nightly smartgwt project build will get fail by a Security Exception.

Could you please help me to resolve this issue. Really appreciate for your suggestion on this.

1. Version
<gwt.version>2.5.1</gwt.version>
<gwt-maven-plugin.version>2.5.1</gwt-maven-plugin.version>
<smartgwt.version>4.0</smartgwt.version>

2. Pom fragment
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>${gwt-maven-plugin.version}</version>
<configuration>
<module>com.fusion.platform.gui.${env}</module>
<includes>**/GuiGwtTestSuite.java</includes>
<timeOut>1800</timeOut>
<testTimeOut>1800</testTimeOut>
<mode>htmlunit</mode>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>

3. Build failed info
[INFO] Compiling module com.fusion.platform.gui.PlatformGui
[ERROR] Exception in thread "Timer-0" java.lang.SecurityException: Could not lock User prefs.Lock file access denied.
[ERROR] at java.util.prefs.FileSystemPreferences.checkLockFil e0ErrorCode(FileSystemPreferences.java:919)
[ERROR] at java.util.prefs.FileSystemPreferences.lockFile(Fil eSystemPreferences.java:908)
[ERROR] at java.util.prefs.FileSystemPreferences.sync(FileSys temPreferences.java:714)
[ERROR] at java.util.prefs.FileSystemPreferences.flush(FileSy stemPreferences.java:807)
[ERROR] at java.util.prefs.FileSystemPreferences.syncWorld(Fi leSystemPreferences.java:451)
[ERROR] at java.util.prefs.FileSystemPreferences.access$1200( FileSystemPreferences.java:33)
[ERROR] at java.util.prefs.FileSystemPreferences$4.run(FileSy stemPreferences.java:419)
[ERROR] at java.util.TimerThread.mainLoop(Timer.java:512)
[ERROR] at java.util.TimerThread.run(Timer.java:462)
[INFO] Validating units:
[INFO] Ignored 252 units with compilation errors in first pass.
[INFO] Compile with -strict or with -logLevel set to TRACE or DEBUG to see all errors.
[INFO] Compiling 6 permutations
[INFO] Compiling permutation 0...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 1...
[INFO] Process output
[INFO] Compiling
[INFO] Compiling permutation 2...
[INFO] Compiling permutation 3...
[INFO] Compiling
[INFO] Compiling permutation 4...
[INFO] Compiling
[INFO] Compiling permutation 5...
[INFO] Compile of permutations succeeded
[INFO] Linking into /local/scratch/build/jenkins/workspace/fusion.mgmt.gui/target/fusion.mgmt.gui-7.0.1.1-3071/platformgui
[INFO] Link succeeded
[INFO] Compilation succeeded -- 137.611s
[ERROR] Exception in thread "Thread-2" java.lang.SecurityException: Could not lock User prefs.Lock file access denied.
[ERROR] at java.util.prefs.FileSystemPreferences.checkLockFil e0ErrorCode(FileSystemPreferences.java:919)
[ERROR] at java.util.prefs.FileSystemPreferences.lockFile(Fil eSystemPreferences.java:908)
[ERROR] at java.util.prefs.FileSystemPreferences.sync(FileSys temPreferences.java:714)
[ERROR] at java.util.prefs.FileSystemPreferences.flush(FileSy stemPreferences.java:807)
[ERROR] at java.util.prefs.FileSystemPreferences.syncWorld(Fi leSystemPreferences.java:451)
[ERROR] at java.util.prefs.FileSystemPreferences.access$1200( FileSystemPreferences.java:33)
[ERROR] at java.util.prefs.FileSystemPreferences$5$1.run(File SystemPreferences.java:429)
[INFO]

Select All Checkbox in ListGrid

$
0
0
SmartClient 9.0 Pro - 12/5/2013

We have a listGrid with SelectionAppearance: "checkbox". The checkbox appears in the column header to allow the user to select or de-select all items. This works fine most of the time. However, if we have at least one row in the grid where canSelect = false, then the header checkbox only serves to check all, and will not de-select all of the selected rows.

I think the behavior should be that if all selectable rows are selected, and you click the header checkbox again, it should de-select them all.

using formItem.readOnlyDisplay:"static", some items value don't show

$
0
0
SmartClient Version: v9.0p_2013-12-14/PowerEdition Development Only (built 2013-12-14)

please try this code in the showcase
Code:

isc.ValuesManager.create({
    ID:"vm",   
    dataSource: countryDS
})
isc.DynamicForm.create({
    ID: "countryList",
    valuesManager:vm,
    width:550, height:224,
    // use server-side dataSource so edits are retained across page transitions
//    dataSource: countryDS,
    // display a subset of fields from the datasource
    fields:[
        {name:"countryCode", title:"Flag", width:40, type:"text", readOnlyDisplay:"static"},
        {name:"countryName", readOnlyDisplay:"static"},
        {name:"continent", readOnlyDisplay:"static"},
        {name:"member_g8", readOnlyDisplay:"static"},
        {name:"population", formatCellValue:"isc.NumberUtil.toUSString(value);"},
        {name:"independence"}
    ],
    canEdit: false
})
vm.fetchData({countryCode:"US"})

countryCode and countryName values will not show. Is it related to the fact that are marked as required in the dataSource?

Custom DS and Paging

$
0
0
v9.0p_2013-12-11/PowerEdition Deployment (built 2013-12-11)

Browser: Firefox 25.0.1
System: Win 7, Win 8

I'm having performance problems using custom DS's.

Basically the situation looks following:
I have a dynamic growing DB table. And i want to load data in to a ListGrid every couple of seconds.

ListGrid :
Code:

               
setDataFetchMode(FetchMode.PAGED);
setDataPageSize(1000);
setShowAllRecords(false);
setShowFilterEditor(true);
setAllowFilterExpressions(true);               
setFastCellUpdates(true);
setShowRollOver(false);
setShowGridSummary(true);                       
setShowRecordComponents(true);                       
setShowRecordComponentsByCell(true);

fetch:
Code:


DataSource dataSource = getMessageGrid().getDataSource();       
                dataSource.setAllowAdvancedCriteria(true);                               
                DSRequest request = new DSRequest();
                request.setSortBy(getMessageGrid().getSort());
                dataSource.fetchData(crit, new DSCallback() {
                        @Override
                        public void execute(DSResponse response, Object rawData, DSRequest request) {               
                                try {
                                        getMessageGrid().setShowFilterEditor(true);
                                        getPresenter().getView().getMassReviewUpperBar().getAdvancedFilter().setDisabled(false);
                                        DataSource dataSource = getMessageGrid().getDataSource();
                                        final ResultSet resultset = new ResultSet();
                                        resultset.setDataSource(dataSource);
                                        resultset.setCriteria(getMessageGrid().getCriteria());
                                        resultset.setFetchMode(FetchMode.PAGED);       
                                        resultset.setInitialLength(response.getTotalRows());
                                        Record[] responseData = response.getData();
                                        Record[] initialData = new Record[response.getEndRow()+1];
                                        for (int i = 0; i <= response.getEndRow()-1; i++) {
                                            if (i < response.getStartRow())
                                                    initialData[i] = null;
                                            else
                                                    initialData[i] = responseData[i-response.getStartRow()];
                                        }
                                        resultset.setInitialData(initialData);
                                        resultset.setInitialSort(getMessageGrid().getSort());
                                        getMessageGrid().setData(resultset);
                                        resultset.destroy();
                                        getMessageGrid().filterByEditor();
                                } catch (ClassCastException e) {
                                        getPresenter().getView().getExportBar().showFinishedWithErrorsLabel();       
                                        getPresenter().getView().getFilterBar().showFinishedWithErrorsLabel();
                                }                               
                      }
               
                }, request);

At the beginning everything works fine i have a small slow down when fetch is called, but with increasing data, the slow down unables the ussage of the appliactation, becouse it becomes so long that the next fetch is called and the circle begins. Ataround 20k of recs the slow down starts to be unhandable. Every next fetch provieds ~1k of records.

The record dosent seam to be to havy

Code:

<fields>
                <field name="id" type="integer" title="id" primaryKey="true" hidden="true"/>
                <field name="bcc" type="text" title="bcc" />
                <field name="cc" type="text" tite="cc" />
                <field name="extern_type" type="integer" title="type"/>
                <field name="hadoop_file_id" type="integer" title="hadoopFieldID" />
                <field name="import_date"  type="date"      title="import_date" />
                <field name="privilege_status" type="integer" title="pStatus"/>
                <field name="recipient" type="text" title="to" />
                <field name="review_status" type="integer" title="reviewed"/>
                <field name="sender" type="text" title="from" />
                <field name="sent_date"  type="datetime" title="datefield"/>
                <field name="subject" type="text" tite="subject" />
                <field name="sys_creation_date"  type="date" title="sys_creation_date"/>
                <field name="technology" type="integer" title="type"/>
                <field name="query_info_id" type="integer" primaryKey="true" title="query_info_id" hidden="true"/>
                <field name="annotated" type="boolean" title="hasAnnotations" />
                <field name="attachments_hadoop_files_ids" type="any" title="attachments_hadoop_files_ids" />
                <field name="source" type="integer" title="source" />
                <field name="risk_level" type="integer" title="risk_level" />
                <field name="review_update_date" type="datetime" title="review_update_date" />
                <field name="employee_id" type="text" title="employee_id" />
                <field name="attachments_hadoop_files_ids" type="text" title="attachments_hadoop_files_ids" />
                               
        </fields>


What i need is that the listgrid can sort/filter during data loading on the already provided data or on the DB table (which grows can grow to even 200k and larger sets records) the data should be paged to sets of 100 - 1k data sets, but the number of total records in grid summary should show the actuall size of the table.

I'm showing the number of records in the summary fields of one of the fields
Code:


subjectField.addSummaryFunction(new SummaryFunction() {
                       
                        @Override
                        public Object getSummaryValue(Record[] records, ListGridField field) {
                                return ""+records.length+" messages";
                        }
                });

Question:
How should I fetch the data?

SmarGWT ListGrid - restoring tree state after adding records to client only Datastore

$
0
0
Problem:
We have a ListGrid that is initialised with data from an RPC call (ListGrid update method 1) - we use _listGrid.getDataSource().setCacheData(<record[]>) and _listGrid.setData(<record[]>) to initialise the data from the RPC call.

The ListGrid is then updated throughout the day from JSON messages pushed over a Socket (ListGrid update method 2). Our app converts the JSON into TargetRecord <extends ListGridRecord> objects and adds them to the client only datastore using the call: _listGrid.getDataSource().addData(newRecord);.
We then call _listGrid.filterData() (to pull the newly added data into the ListGrid) and _listGrid.resort() (this restores the treestate of open folders prior to the filterData() call).
If we receive JSON that matches the record selected in the ListGrid, that record is updated in the grid.
This works ok when we have selected a ListGrid record that was loaded from RPC data (Method 1 above).
However, if we select a record that was added using Method 2, we start running into Class Cast errors with line 2 below:
Code:

final RecordList recordList = _listGrid.getDataAsRecordList();
final TargetRecord oldRecord = (TargetRecord) recordList.find(Constants.FIELD_PK, target.getTgtID());

We have worked around this using:
Code:

final Record record = recordList.find(Constants.FIELD_PK, target.getTgtID());
TargetRecord oldRecord = new TargetRecord(record.getAttributeAsString(Constants.FIELD_PK), record.getAttributeAsString(Constants.FIELD_INSTRUMENT), etc...);

But now the resort() does not restore the tree state so we are trying to handle this ourselves by using:
Code:

final ListGridRecord selectedRecord = _listGrid.getSelectedRecord();
...
if (selectedRecord != null) {
    _listGrid.selectRecord(selectedRecord);

final TreeNode parentNode = _listGrid.getGroupTree().getParent(new TreeNode(selectedRecord.getJsObj()));
// open the node hierarchy of selected record
_listGrid.getGroupTree().openFolder(parentNode);
}

However, despite the fact that selectedRecord is not null, the record does not select in the listGrid, nor does the parent folder open.

1. SmartGWT version: SmartClient Version: v9.0p_2013-10-28/LGPL Development Only (built 2013-10-28)

2. Any browser

3. server-side problem: N/A

4. problem processing a server response: N/A

5. JavaScript error, the stack trace logged in the Developer Console (see FAQ)

6. sample code: can be provided.

How do I get the non-null selected record object to reselect in the grid so I can open the node hierarchy of folders?

Adding a row using foreign (includeFrom) field?

$
0
0
I'm using Isomorphic SmartClient/SmartGWT Framework (v9.0p_2013-09-17/Pro Deployment 2013-09-17) and using serverside datasources...

my ds.xml looks like this:
Code:


<DataSource ID="app_users" serverType="sql" dataSourceVersion="1" autoDeriveSchema="true">
    <fields>
        <field name="id" type="sequence" primaryKey="true">
            <columnCode>b80bb7740288fda1f201890375a60c8f</columnCode>
        </field>
        <field name="app_id" foreignKey="apps.id"/>
        <field name="user_id" foreignKey="users.id"/>
        <field name="create_date" type="datetime">
            <columnCode>3d8252a0fb3ab8a64613f6f814ed08ca</columnCode>
        </field>
        <field name="enabled" type="integer">
            <columnCode>a10311459433adf322f2590a4987c423</columnCode>
        </field>
        <field name="is_admin" type="integer">
            <columnCode>c60879c6b41321704ee88fbc7b9a73e4</columnCode>
        </field>         
        <field name="app_name" includeFrom="apps.name"/>
        <field name="app_enabled" includeFrom="apps.enabled"/>
        <field name="user_name" includeFrom="users.name"/>
        <field name="user_enabled" includeFrom="users.enabled"/>                               
    </fields>
    <allowAdvancedCriteria>false</allowAdvancedCriteria>
    <tableCode>43738f9fce49550bbb66a533c637b647</tableCode>
    <generatedBy>v9.0p_2013-09-17/Pro Deployment 2013-09-17</generatedBy>
</DataSource>

when I use this code to add a new entry, it fails
Code:

            DataSource ds = DataSourceManager.get(getDataSource());
            Map<String,Object> record = new HashMap<String,Object>();           
            record.put("user_name", name);
            record.put("app_name", appName);
            record.put("create_date", new Date());
            ds.add(record);

with "Field 'app_id' doesn't have a default value"

but if I do two separate lookups/DB calls to get the actual DB ids of username (userId) and appname (appId), and use those ids in the call instead, it works:
Code:

        //for some reason, when doing an add, you have to have the DB ids
        long appId = getAppId(appName);
        long userId = getId(DS_USERS, name);
       
            DataSource ds = DataSourceManager.get(getDataSource());
            Map<String,Object> record = new HashMap<String,Object>();           
            record.put("user_id", userId);
            record.put("app_id", appId);
            record.put("create_date", new Date());
            ds.add(record);

Is there some trick to getting add to work with the foreign fields? or does this not work like I assumed it would?

Thanks,
Brian

ListGrid.startEditingNew and canEditCell

$
0
0
Environment:
smartgwt-4.0p-2013-12-17

When editing a new list grid record with startEditingNew(defaultValues), the default values are not provided any more in
Code:

protected boolean canEditCell(int rowNum, int colNum) {
Record record = getEditedRecord(rowNum);
}

This worked at least until 3.0p-2013-01-08.
Now canEditCell seems first to be invoked with an empty record and then again with the record containing the default values.
I have expected that before canEditCell is invoked, the new record is populated with the default values.
Has this been intentionally changed or is this a bug?

Example, drawn from the showcase "grid_editing_new_row"
Code:

@Override
    public void onModuleLoad() {
        Canvas canvas = new Canvas();
        final ListGrid countryGrid = new ListGrid() {
            @Override
            protected boolean canEditCell(int rowNum, int colNum) {
                Record editedRecord = getEditedRecord(rowNum);
                ListGridField f = this.getField(colNum);
                System.out.println("Row/Col=" + rowNum + "/" + colNum +  ", Fname=" + f.getName() + ", EditedRecord.countryName=" + editedRecord.getAttribute("countryName"));
                return super.canEditCell(rowNum, colNum);
            }
        };
        countryGrid.setWidth(550);
        countryGrid.setHeight(224);
        countryGrid.setShowAllRecords(true);
        countryGrid.setCellHeight(22);
        countryGrid.setID("countryList");
        countryGrid.setDataSource(CountryXmlDS.getInstance());

        ListGridField nameField = new ListGridField("countryName", "Country");
        countryGrid.setFields(nameField);

        countryGrid.setAutoFetchData(true);
        countryGrid.setCanEdit(true);
        countryGrid.setEditEvent(ListGridEditEvent.CLICK);
        countryGrid.setListEndEditAction(RowEndEditAction.NEXT);
        canvas.addChild(countryGrid);

        IButton button = new IButton("Edit New");
        button.setTop(250);
        button.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Map<String, String> map = new HashMap<String, String>();
                map.put("countryName", "whatever");
                countryGrid.startEditingNew(map);
            }
        });
        canvas.addChild(button);

        canvas.draw();
    }

    public static class CountryXmlDS extends DataSource {

        private static CountryXmlDS instance = null;

        public static CountryXmlDS getInstance() {
            if (instance == null) {
                instance = new CountryXmlDS("countryDS");
            }
            return instance;
        }

        public CountryXmlDS(String id) {

            setID(id);
            setRecordXPath("/List/country");
            DataSourceIntegerField pkField = new DataSourceIntegerField("pk");
            pkField.setHidden(true);
            pkField.setPrimaryKey(true);

            DataSourceTextField countryNameField = new DataSourceTextField("countryName", "Country");
            countryNameField.setRequired(true);

            setFields(pkField, countryNameField);

            setClientOnly(true);
        }
    }

Output when editing a new record:
Code:

Row/Col=0/0, Fname=countryName, EditedRecord.countryName=null
Row/Col=0/0, Fname=countryName, EditedRecord.countryName=whatever
Row/Col=0/0, Fname=countryName, EditedRecord.countryName=whatever

Problems with rows marked as Removed in ListGrid

$
0
0
Hi

I have encountered problems when I want to mark rows as removed in a ListGrid.

1) The method markSelectionRemoved doesn't seem to work. When I select several rows and I call this method, only one row is marked as removed.
A workaround is to use the method markRecordRemoved which works fine.

2) I have another weird behavior if I initialize the ListGrid with setShowGridSummary(true).
- I mark one or several rows as removed
- I edit another row
- the "removed" rows are not marked as removed anymore
Any idea ?

I'm using :
- SmartGWT4.0
- GWT 2.5.1

FormItem icons and hint text

$
0
0
Hi...

Is there a way to switch the order of the hint text and the icons of a FormItem? Sometimes it makes more sense to have the text first and afterwards the icons - if I have a TextItem and I want to specify to the user that the units for the entered value are mm, the text should be before the eventual icons...


Regards
Stefan

MultiComboBoxItem: setting values pragmatically

$
0
0
Hello,
I am using SmartGWT 4.1 and Firefox 25.0.1

I am trying to set the value of MultiComboBoxItem from a user input pragmatically and keeping the old value of it.

the setValues function is not updating the MultiComboBoxItem value and it does not reflect the changes.

Here is a snippet of the code (I could not attach the project that reproduce the problem due a server error from your side).

Code:



        final CompanyComboBox concepts = new CompanyComboBox();
                final DynamicForm conceptsForm = new DynamicForm();
               
                final TextItem item=new TextItem();
                conceptsForm.setFields(concepts,item);
                this.addMember(conceptsForm);
               
                Button button=new Button("Add New KPI");
               
                button.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
                       
                        @Override
                        public void onClick(com.smartgwt.client.widgets.events.ClickEvent event) {
                       
                                String[] values = concepts.getValues();
                                final String[] newValues=new String[values.length+1];
                                int j=0;
                                for (int i = 0; i < values.length; i++) {
                                        String string = values[i];
                                        newValues[j]=string;
                                        j++;
                                       
                                }
                                newValues[values.length]=item.getValueAsString();
                       
                       
                                concepts.setValues(newValues);
                        }
                });
                this.addMember(button);

Code:


public class CompanyComboBox  extends MultiComboBoxItem{

       
        final MultiComboBoxLayoutStyle initialLayoutStyle = MultiComboBoxLayoutStyle.VERTICAL;
        public CompanyComboBox(){
                super();
                this.setTitle("Comapny");
                this.setOptionDataSource(new CompanyListDataSource());
                this.setDisplayField("orgLabel");
                this.setValueField("orgLabel");
                this.setLayoutStyle(initialLayoutStyle);
                this.setShouldSaveValue(true);
                this.setAlwaysFetchMissingValues(false);
                this.setAutoFetchData(true);
               
               
        }
}

Viewing all 4756 articles
Browse latest View live