Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    #16
    Entrypoint class:

    Code:
    public class CountryDataDemo implements EntryPoint {
    
        protected boolean isTopIntro() {
            return true;
        }
    
        public class ListGridItem extends CanvasItem {
    
            ListGridItem(String name) {
                super(name);
                setEndRow(true);
                setStartRow(true);
                setColSpan("*");
                setShowTitle(false);
                setInitHandler(new FormItemInitHandler() {
    
                    @Override
                    public void onInit(FormItem item) {
                        ListGrid grid = new ListGrid();
                        grid.setWidth(700);
                        grid.setHeight(700);
                        grid.setLeaveScrollbarGap(false);
                        grid.setFields(((ListGridItem) item).getGridFields());
                        grid.setData(((ListGridItem) item).getGridData());
                        grid.setAutoFetchData(true);
                        grid.setCanEdit(true);
    
                        grid.setEditorCustomizer(event -> {
                            if (event.getEditField().getName().equals("capitalId")) {
                                return new CustomTextItem(event, grid);
                            }
                            return event.getDefaultProperties();
                        });
                        ((CanvasItem) item).setCanvas(grid);
                    }
                });
            }
    
            private ListGridRecord[] gridData;
    
            public void setGridData(ListGridRecord[] gridData) {
                this.gridData = gridData;
            }
    
            public ListGridRecord[] getGridData() {
                return gridData;
            }
    
            private ListGridField[] gridFields;
    
            public void setGridFields(ListGridField... gridFields) {
                this.gridFields = gridFields;
            }
    
            public ListGridField[] getGridFields() {
                return gridFields;
            }
        };
    
        @Override
        public void onModuleLoad() {
            final DynamicForm exampleForm = new DynamicForm();
            exampleForm.setLeft(200);
            exampleForm.setCanDragResize(true);
            exampleForm.setBorder("3px solid #0083ff");
    
            ListGridItem countryField = new ListGridItem("countryName");
            countryField.setGridData(CountrySampleData.getRecords());
    
            ListGridField country = new ListGridField("countryName", "Country");
    
            /* id field with displayField */
            ListGridField capital = new ListGridField("capitalId", "Capital");
            capital.setDisplayField("capitalDescription");
            capital.setValueField("capitalId");
    
            countryField.setGridFields(country, capital);
    
            TextItem emailField = new TextItem("Email");
    
            exampleForm.setFields(countryField, emailField);
    
            HLayout panel = new HLayout();
    
            panel.setMembers(exampleForm);
            panel.draw();
        }
    
    }
    
    class CustomTextItem extends TextItem {
    
        public CustomTextItem(ListGridEditorContext context, ListGrid grid) {
            Window popUp = new Window();
            popUp.setIsModal(true);
            popUp.setShowCloseButton(true);
            popUp.setShowMinimizeButton(false);
            popUp.setCanDragResize(true);
            popUp.setCanDrag(true);
            popUp.setCanDrop(true);
            popUp.setCanDragReposition(true);
            popUp.setKeepInParentRect(true);
    
            Button button = new Button("Set edit values");
    
            button.setTop(100);
            button.setLeft(400);
            button.setWidth("100");
            button.setHeight("50");
    
            popUp.addChild(button);
    
            button.addClickHandler(event -> {
                /* I am providing the value of display field as well but it shows ID 19 */
                grid.setEditValue(context.getRowNum(), "capitalId", "19");
                grid.setEditValue(context.getRowNum(), "capitalDescription", "SomeCapital");
                popUp.close();
            });
            this.setCanEdit(false);
            addClickHandler(event -> {
                popUp.setRect(1200, 350, 900, 500);
                popUp.centerInPage();
                popUp.setShowCloseButton(false);
                popUp.show();
    
            });
            setFetchMissingValues(false);
            setUseLocalDisplayFieldValue(true);
        }
    }

    Data class:
    Code:
    public class CountrySampleData {
    
        private static ListGridRecord[] records;
    
        public static ListGridRecord[] getRecords() {
            if (records == null) {
                records = getNewRecords();
            }
            return records;
        }
    
        public static ListGridRecord createRecord(String countryName, int capitalId, String capitalDesc) {
            ListGridRecord record = new ListGridRecord();
            record.setAttribute("countryName", countryName);
            record.setAttribute("capitalId", capitalId);
            record.setAttribute("capitalDescription", capitalDesc);
            return record;
        }
    
        public static ListGridRecord[] getNewRecords() {
            return new ListGridRecord[] { createRecord("United States", 1, "Washington, DC"), createRecord("China", 2, "Beijing") };
        }
    }


    HTML :

    Code:
    <!doctype html>
    <!-- The DOCTYPE declaration above will set the     -->
    <!-- browser's rendering engine into                -->
    <!-- "Standards Mode". Replacing this declaration   -->
    <!-- with a "Quirks Mode" doctype is not supported. -->
    
    <html>
      <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!--     <meta name="gwt:property" content="locale=de"> -->
    
        <!--                                                               -->
        <!-- Consider inlining CSS to reduce the number of requested files -->
        <!--                                                               -->
        <link type="text/css" rel="stylesheet" href="CountryDataDemo.css">
    
        <!--                                           -->
        <!-- Any title is fine                         -->
        <!--                                           -->
        <title>Country Data</title>
    
        <!--                                           -->
        <!-- This script loads your compiled module.   -->
        <!-- If you add any GWT meta tags, they must   -->
        <!-- be added before this line.                -->
        <!--                                           -->
        <script type="text/javascript" language="javascript">var isomorphicDir = "/countrydatademo/sc/"</script>
        <script type="text/javascript" language="javascript" src="countrydatademo/countrydatademo.nocache.js"></script>
    
        <script src="countrydatademo/sc/modules/ISC_Core.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Foundation.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Containers.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Drawing.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Grids.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Charts.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Forms.js"></script>
        <script src="countrydatademo/sc/modules/ISC_RichTextEditor.js"></script>
        <script src="countrydatademo/sc/modules/ISC_Calendar.js"></script>
        <script src="countrydatademo/sc/modules/ISC_DataBinding.js"></script>
        <script src="countrydatademo/sc/skins/Tahoe/load_skin.js"></script>
    
      </head>
      <body>
    
    <script src="countrydatademo/sc/DataSourceLoader?dataSource=countrydatasource"></script>
    <script src="countrydatademo/sc/DataSourceLoader?dataSource=supplyItem"></script>
         <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
        <noscript>
          <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
            Your web browser must have JavaScript enabled
            in order for this application to display correctly.
          </div>
        </noscript>
    
        <table align="center">
          <tr>
            <td colspan="2" style="font-weight:bold;"></td>
          </tr>
          <tr>
            <td id="formContainer"></td>
            <td id="buttonContainer"></td>
          </tr>
          <tr>
            <td colspan="2" style="color:red;" id="errorLabelContainer"></td>
          </tr>
        </table>
      </body>
    </html>


    I guess that will be considered as ready to run test case. Editing the capital field will open a window and clicking the button on window will reproduce the issue.
    I hope this helps in reproducing the issue.

    Comment


      #17
      Removed as posted again by mistake.

      Comment


        #18
        There's no need to guess as to what a complete test case is, since in the text right below where you type your forums post, it is defined, with a link to further details.

        This test case is slightly overkill, in that we don't generally need a .html launch file. However, it is also broken, as it loads DataSources we don't have, and also doesn't apply DataSources to any of the widgets, so it can't possibly demonstrate any requests to DataSources.

        Comment


          #19
          Not sure why it's not running . As I am new here I am finding hard to provide you the ready to run scenario. I've uploaded the running dummy example https://rb.gy/zdlxz9 with just 2 classes. This will run as it is on any IDE.

          Comment


            #20
            This is quickly becoming absurd..

            This test code does not use any DataSources. You are claiming you are seeing requests to a DataSource. The framework is not capable of making requests to DataSources when there are no DataSources.

            So please show us what those requests look like... you can look in the RPC tab of the Developer Console.

            Comment


              #21
              This thread started with extra calls issue but it's not the issue anymore. Now the only issue is id visible instead of displayValue while I am setting both using setEditValue.
              I created the above test project just for this purpose where I used a field with displayField.

              The above sample is not using any datasource. I am providing the data using

              Code:
              grid.setData(((ListGridItem) item).getGridData());
              It's happening for both DS bound and non DS bound grids.

              For this reason there is no call in isc console. Attaching a gif to show the exact issue.

              Click image for larger version

Name:	captured.gif
Views:	10
Size:	2.46 MB
ID:	263797

              Comment


                #22
                By design, we do not look for edit values when looking up displayField values. A field used as a displayField is always hidden, since otherwise, you would clearly be showing the same value in two columns. Because the field is always hidden, the idea of editValues for it makes no sense.

                Just put the displayValue into the record, rather than trying to have it as an editValue.

                Comment

                Working...
                X