Announcement

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

    Odd selection problem with comboBox

    Greetings,

    We're using version 8 pro. This is the GA version, not a nightly build. I've got a really strange problem that has been around for a while and I can't figure out what the problem is. I have isolated it to the isomorphic code, meaning that it's most definitely not the data coming back from the datasource.

    I'm using the combobox for a typeahead search. As you type a company name, a list of companies drops down. It works great, except in a couple of instances where clicking on a record gives me a different company, the one above it. Every single time. And only when these two companies are listed together.

    Below is a snapshot of the RPC trace, you can see the data. When I click on the first company_code:"800626", item.getSelectedRecord() gives me the record I selected. When I click on the last company, company_code:"20699", I get the correct record back. But when I click on the second company, company_code:"300626", I don't get that company I get the first company 800626. This happens no matter how many companies I have. The list can be 40 rows and it still happens, and only on these two records - 300626 and 800626 get confused. There are a few other searches where it happens with certain companies, but it's very esoteric. It only happens with a few companies and only when they are listed together.

    In test case is below I limited the resultset on the server side to just three companies to isolate the problem. In the item changed section you can see where I get the record, var company = item.getSelectedRecord().script; and then just below that you can see the alert. That alert shows me the data for the first company when the second one was clicked on. I've also put a breakpoint using IE's javascript debugger and looked at the object returned by getSelectedRecord(). And it's in fact the wrong object. The one returned is for the first company, not the one I selected.

    I've been very careful with the testing, and this is repeatable every time. Do you have any idea why this would happen?

    S

    Code:
    	isc.DynamicForm.create({
    	    fields:[
    	        {prompt:"Search for companies by entering a ticker symbol, full or partial company name, NAIC code, or group name.",
    	        	hint:"Enter ticker, name, NAIC code or group", 
    	            showHintInField:true, 
    	            name:"qsSearchField",
    	            ID:"searchField",
    	            showPickerIcon:false,
    	            showFocused:true,
    	            selectOnFocus:true,
    	            optionDataSource: "GlobalQuickSearchDataSource", editorType: "comboBox",
    	            showTitle:false, width:420, pickListHeaderHeight:1,
    	            pickListFields: [
    								 {name: 'company_code_dis', showTitle:false, width:48},
    								 {name: 'stmt', showTitle:false, width:38},
    								 {name: 'company_name', ID:'company_name', showTitle:false, width:260},
    	                             {name: 'ticker', showTitle:false, width:50},
    	                             {name: 'company_code_dis', showIf:"false"},
    	                             {name: 'ins_type', showIf:"false"},
    	                             {name: 'script', showIf:"false"},
    	                             {name: 'subscribed', showIf:"false"}
    	                            ],
    	           	getPickListFilterCriteria : function () {
    	                   		var value = this.getDisplayValue();
    	                   		if (value == '') {
    								value=' ';
    		                   }
    	    	               	return {value:value};
    	             }          		 
      	        }//,
               	//{startRow:false, disabled:true, name:"findbtn", editorType:"button", width:100, title:"Find", click:"layoutViewController('quickSearch');quickSearch(quickSearchForm.getValue('qsSearchField'))"}            
               	
    	    ],
       		itemChanged: function (item, newValue) {
       			var showAll = false;
       			try {
       				var resultString = "Show all results for";
       				var strIndex = newValue.indexOf(resultString);
    	    		if (strIndex > -1) {
    	    			layoutViewController('quickSearch');
    	    			quickSearch(newValue.substr(resultString.length+1));
    	    			searchTerm = newValue.substr(resultString.length+1);
    	    			showAll = true;
    	    		}
    	    		 
       			} catch (err) {
       				//alert("D100 An exception occurred. " + " Error name: " + err.name + ". Error message: " + err.message);
       			}
       			try {
       	   			if (!showAll) {
    	   			var company = item.getSelectedRecord().script;
    		    		var hrefLink = 'javascript:';
    		    		var jsString = company.substr(hrefLink.length);
    		    		alert(company);
    		    		//eval(jsString);
    		    		document.location.href=company;
       	   			}
    				   				
       			}catch (err) {}
    		},
    	    ID:"quickSearchForm",
    	    autoDraw:false
    	})
    Code:
    [
        {
            queueStatus:0, 
            invalidateCache:false, 
            data:[
                {
                    ticker:"", 
                    stmt:"", 
                    company_code_dis:"", 
                    company_name:"Show all results for ace"
                }, 
                {
                    ins_type:"8", 
                    script:"/iap/ng/jsp/companyIntelligence/viewCompanyIntel.jsp?it=8&cc=E0626", 
                    stmt:"ENT", 
                    company_code:"800626", 
                    company_code_dis:"E0626", 
                    company_name:"ACE Ltd Group*"
                }, 
                {
                    ins_type:"1", 
                    script:"/iap/ng/jsp/companyIntelligence/viewCompanyIntel.jsp?it=1&cc=P0626", 
                    stmt:"P&C", 
                    company_code:"300626", 
                    company_code_dis:"P0626", 
                    company_name:"ACE Ltd Group*"
                }, 
                {
                    ins_type:"1", 
                    script:"/iap/ng/jsp/companyIntelligence/viewCompanyIntel.jsp?it=1&cc=20699", 
                    stmt:"P&C", 
                    company_code:"20699", 
                    company_code_dis:"20699", 
                    company_name:"Ace Prop & Cas Ins Co"
                }
            ], 
            status:0, 
            totalRows:4, 
            isDSResponse:true
        }
    ]

    #2
    Here is the datasource definition, I thought you might want to see that too:

    Code:
    <DataSource ID="GlobalQuickSearchDataSource" titleField="company_name" serverType="generic" dataFormat="iscServer">
    	<fields>
    		<field name="company_code_dis"  type="text"  	title="Company Code"  primaryKey="true"/>
    		<field name="company_code"  	type="integer"  hidden="true"	/>
    		<field name="company_name"  	type="text"  	title="Company Name"   	/>
            <field name="stmt"      		type="text"  	title="Ins Type"		/>
            <field name="ticker"   			type="text"  	title="Ticker"			/>
            <field name="group_name"    	type="text"  	title="Group Name"		/>
            <field name="group_code"  		type="text"  title="Group Code"		/>
            <field name="yq_flag"  			type="integer"  hidden="true"			/>
            <field name="ins_type"        	type="integer" 	hidden="true"			/>
            <field name="state_of_domicile"    		type="text"  	title="State"			/>
            <field name="a3"        		type="integer"  	title="Annual Assets"	/>
            <field name="a4"        		type="integer"  	title="Annual DPW"		/>
            <field name="data_as_of"       	type="date" 	title="Data as of"		/>
            <field name="subscribed"		type="boolean" hidden="true"	/>
            <field name="script"			type="text" hidden="true"	/>
    	</fields>        	
        <serverObject lookupStyle="new" className="com.insx.isomorphic.ds.SearchController" />
        <operationBindings>
            <binding operationType="fetch" serverMethod="fetchData" methodArguments="$request, $dsRequest, $response"/>
        </operationBindings>
    </DataSource>

    Comment


      #3
      Okay I've got more information now... this happens when the company names are identical. I can repeat that now. So it looks like the key should be strengthened. Seems like primary key on company_code_dis should work, shouldn't it?

      Comment


        #4
        Right - the ComboBoxItem doesn't store the whole record, just the field indicated as the valueField (or as comboBoxItem.name). So that field needs to be unique.

        Comment

        Working...
        X