Announcement
Collapse
No announcement yet.
X
-
As you seem to have realized while talking it through, there is no good way for the framework to automatically deal with all the messy things that might appear in uploaded data. It's a job for application-specific custom code, as we previously suggested.
-
Hi Isomorphic,
what do you mean by "uploadDataSource"? The DMI reference in the .ds.xml? I could do it there, but this does not seem right.
IMHO it should be possible to have explicit false values in the csv-data as well.
As the specific string is not going to be language-agnostic, but more locale-specific like a date, it should have a per-locale default, which can be changed.
Why should by default "foobar" be translated to true? Why should it not make validation fail by default?
Why should by default "no" be translated to true?
I don't have the problem, but how would you tell apart NULL and false in an import with the way things are?
As there is a workaround with DMI, which I'm going to use now, this perhaps is more of an enhancement and not a bug, but it is definitely is not good default behavior, more like PHP :)
Best regards
Blama
Leave a comment:
-
As you mentioned, empty cells work for false. For those other values, you would add custom logic in an uploadDataSource.
Leave a comment:
-
Hi Isomorphic,
I'm talking about something else - Boolean conversion for CSV-BatchImports. How am I supposed to transmit an false value?
Everything is treated as true if you run the testcase.
As I wrote I added the .ds.xml just to match my configuration and suggested a *similar* attribute for CSV-imports.
Best regards
Blama
Leave a comment:
-
This is expected - the SQLStorageStrategy affects storage only and has no impact outside of the SQL layer - anyone using the DataSource API (client or server) is unaware of the translation and just sees a normal Boolean field.
If you wanted to accept additional values for a Boolean field on import, you could do that via custom code in your uploadDataSource.
Leave a comment:
-
5.1 BatchUploader: How to upload "false"-value to boolean field?
Hi Isomorphic,
I'm having trouble to upload "false" to a type="boolean" sqlStorageStrategy="singleCharYN"-ds.xml field (v10.1p_2016-03-27).
The framework seems to only recognize empty cells as "false", and not one of "N", "false", "False", "No".
supplyItem.ds.xml inStock-addition to match my configuration:
BuiltInDS.java:Code:sqlStorageStrategy="singleCharYN"
See the attached CSV-file for a example.Code:package com.smartgwt.sample.client; import com.google.gwt.core.client.EntryPoint; import com.smartgwt.client.core.KeyIdentifier; import com.smartgwt.client.data.DataSource; import com.smartgwt.client.util.Page; import com.smartgwt.client.util.PageKeyHandler; import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.BatchUploader; import com.smartgwt.client.widgets.IButton; import com.smartgwt.client.widgets.Window; import com.smartgwt.client.widgets.events.ClickEvent; import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.layout.VLayout; public class BuiltInDS implements EntryPoint { public void onModuleLoad() { KeyIdentifier debugKey = new KeyIdentifier(); debugKey.setCtrlKey(true); debugKey.setKeyName("D"); Page.registerKey(debugKey, new PageKeyHandler() { public void execute(String keyName) { SC.showConsole(); } }); VLayout mainLayout = new VLayout(20); mainLayout.setWidth100(); mainLayout.setHeight100(); IButton recreateBtn = new IButton("Recreate"); recreateBtn.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { recreate(); } }); mainLayout.addMember(recreateBtn); recreate(); mainLayout.draw(); } private void recreate() { Window w = new Window(); w.setWidth("95%"); w.setHeight("95%"); w.setMembersMargin(0); w.setModalMaskOpacity(70); w.setTitle("Import data"); w.setShowMinimizeButton(false); w.setIsModal(true); w.setShowModalMask(true); w.centerInPage(); BatchUploader batchUploader = new BatchUploader(); batchUploader.setWidth100(); batchUploader.setUploadDataSource(DataSource.get("supplyItem")); batchUploader.setDefaultDelimiter(","); batchUploader.setDefaultQuoteString("\""); ListGridField itemName = new ListGridField("itemName"); ListGridField sku = new ListGridField("SKU"); ListGridField category = new ListGridField("category"); ListGridField unitCost = new ListGridField("unitCost"); ListGridField inStock = new ListGridField("inStock"); batchUploader.setGridFields(itemName, sku, category, unitCost, inStock); w.addItem(batchUploader); w.show(); } }
I'd say that the correct solution would be to have uploadFieldTrueValue and uploadFieldFalseValue-attributes (or similar named) in the .ds.xml that have (like date-fields) locale-specific defaults.
Best regards
BlamaAttached FilesTags: None
Leave a comment: