Search and Default Editor

4878
22
Jump to solution
12-04-2015 08:36 AM
RickeyFight
MVP Regular Contributor

I am getting a weird result when I search for a location.

I have the Editor widget  and Search basic combined.

When I search for a location, I can zoom to it. Then when I click on any other point to edit it, I get this result:

Has anyone dealt with this?

i think I am looking for a way to clear search when I click anywhere not the search point.

Even when I clear the search bar I still cannot click on a point to edit:

0 Kudos
1 Solution

Accepted Solutions
RickeyFight
MVP Regular Contributor

Robert!

I figured out a way around it!!!!!

      var search = new Search({ 
        map: map,
  enableButtonMode: true,
  enableInfoWindow: false,
  enableHighlight: false,
  enableLabel: false
      }, "search"); 
      search.startup(); 

I stopped the Infowindow from opening which is why it was not working in the first place.

Since I answered the question I will make mine as correct but thank you so much for the help through this process!

View solution in original post

0 Kudos
22 Replies
RobertScheitlin__GISP
MVP Emeritus

Rickey,

   This is a known feature with the API and you have to re-initialize the editor widget to overwrite the changes to the popup made by the search widget. I have seen a couple of threads on this but I don't have the links off hand.

RickeyFight
MVP Regular Contributor

Robert,

Thank you I will search harder for them

0 Kudos
RickeyFight
MVP Regular Contributor

I have searched for an example for a few hours and cannot find any.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Here is the thread with the advice from Kelly:

Bug? Editor Widget & Search Widget not playing nice together

RobertScheitlin__GISP
MVP Emeritus

Rickey,

   Did the link I provided answer your question?

RickeyFight
MVP Regular Contributor

Robert,

Sort of,  I got the search to clear, but I cannot get the editor to reinitialize.

I am still working with the code.

0 Kudos
RickeyFight
MVP Regular Contributor

Robert,

I am getting hung up on the destroyEditor part.

            var search = new Search({
                map: map
            }, "search");

            search.startup();


            search.on("select-result", lang.hitch(this, function () {
                //if edit tool is enabled we'll have to delete/create
                //so info window behaves correctly.
                on.once(this.map.infoWindow, "hide", lang.hitch(this, function () {
                    search.clearGraphics();
                    console.log("Cleared Search Graphics");
              
                       _destroyEditor();
                        console.log("Test");
                       initEditing();

                           }));
            }));

             function _destroyEditor() {
                   if (this.editor) {
                        this.editor.destroy();
  console.log("Destroyed editor");
                        this.editor = null;    
                    }
                }


            function initEditing(event) {
                var featureLayerInfos = arrayUtils.map(event.layers, function (layer) {
                    return {
                        "featureLayer": layer.layer,
                        "isEditable": true,
                        'showAttachments': true,
                        "showDeleteButton": false,
                        "fieldInfos": [{
                            'fieldName': 'Caller_Name',
                            'isEditable': false,
                            'tooltip': 'Caller Name',
                            'label': 'Caller Name:'
            }, {
                            'fieldName': 'Priority',
                            'isEditable': true,
                            'tooltip': 'Priority',
                            'label': 'Priority:'
            }, {
                            'fieldName': 'Location',
                            'isEditable': false,
                            'label': 'Location:'
            }, {
                            'fieldName': 'Phone',
                            'isEditable': false,
                            'label': 'Phone:'
            }, {
                            'fieldName': 'Notes',
                            'isEditable': true,
                            'label': 'Notes:'
            }, {
                            'fieldName': 'CallType',
                            'isEditable': true,
                            'label': 'CallType:'
            }]
                    };
                });


                var settings = {
                    map: map,
                    layerInfos: featureLayerInfos
                };
                var params = {
                    settings: settings
                };


                var editorWidget = new Editor(params, 'editorDiv');
                editorWidget.startup();


                //snapping defaults to Cmd key in Mac & Ctrl in PC.
                //specify "snapKey" option only if you want a different key combination for snapping
                map.enableSnapping();
            }
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Rickey,

   You are creating a local var for your editor when you init your editor and the example Kelly is using creates a global var for the editor called this.editor

RickeyFight
MVP Regular Contributor

Robert,

I mostly realize what is happening, I just am not 100% sure how to fix it.

What is happening now is that when the editor tries to reinitialize I get this error:

Uncaught TypeError: Cannot read property 'layers' of undefined

I realize that this:

   var featureLayerInfos = arrayUtils.map(event.layers, function (layer) {

is a local variable but I am unsure how to make it global.

0 Kudos