custom excell code help

Hi,
i created a custom excell using the following code.



function eXcell_mytime(cell){                                    //excell name is defined here
			      if (cell){                                                     //default pattern, just copy it
			          this.cell = cell;
			          this.grid = this.cell.parentNode.grid;
			      }
			      this.setValue=function(val){
			    	  if(val == ""){
			    		  var opts = get_options();
				          var row_id = this.cell.parentNode.id;
				          this.cell.innerHTML="<select id='combo_'"+row_id+" style='width:250px;'>"+opts+"</select>";
				          
			    	  }
			    	  else{
			    		  this.setCValue(val);
			    	  }
			                                  
			      }
			      this.getValue=function(){
			         return this.cell.innerHTML; // get value
			      }
			      this.edit=function(){
			          this.val = this.getValue(); //save current value
			          var opts = get_options();
			          var row_id = this.cell.parentNode.id;
			          this.cell.innerHTML="<select id='combo_'"+row_id+" style='width:250px;'>"+opts+"</select>"; // editor's html
			          this.cell.firstChild.value=parseInt(val); //set the first part of data
			          this.cell.childNodes[0].onclick=function(e){ (e||event).cancelBubble=true; } //block onclick event
			            
			      }
			      this.detach=function(){
			          this.setValue(this.cell.childNodes[0].value); //set the new value
			          return this.val!=this.getValue();    // compare the new and the old values
			      }
			  }
			  eXcell_mytime.prototype = new eXcell;    // nest all other methods from base class

But this excell is not working correctly,I am unable to select the item from the drop down list created using the excell code.

Is there some problem in the code? Please help soon, i have been stuck on it for two weeks. :frowning:

The get_options() function is defined as follows:

function get_options(){
var loader = dhtmlxAjax.postSync("combo_opts.jsp");
if(loader.xmlDoc.responseText != null){
return loader.xmlDoc.responseText;

selecting of the options in your select works well for us.
Please, make sure that you’ve provided the actual code.
in the provided sample you need replace
this.cell.firstChild.value=parseInt(val); //set the first part of data
with
this.cell.firstChild.value=parseInt(this.val); //set the first part of data

also, please, check your response from the get_options() function.

Hi,
can it be because my options are actually text?
the options are something like “ABD::123.23.00”
If this is so what do i need to replace parseInt with?

Thank you,
changing this.cell.firstChild.value=parseInt(val); //set the first part of data
to
this.cell.firstChild.value=parseInt(this.val); //set the first part of data
worked :smiley:

Great! :smiley:
Sorry for the typo in the documentation, it will be fixed in the near time.

Just one question,
Is it possible to convert the select to combo using standard version?
I want the filtering functionality.

dhtmlXComboFromSelect method should help you.
Something like this:

... this.cell.innerHTML="<select id='combo_'"+row_id+" style='width:250px;'>"+opts+"</select>"; // editor's html this.cell.firstChild.value=parseInt(this.val); //set the first part of data var z=dhtmlXComboFromSelect('combo_'+row_id)

Note the the js, css files of dhtmlxCombo should be added to your page.

Thanks a lot for your help. it is working now. :slight_smile:

Hi,
i am sorry, I must have misunderstood something. :frowning:
My grid now shows a combo box with filtering, but when i select the option from the combo, it shows “undefined” in the grid.
Whereas if I remove the statements

var z = dhtmlXComboFromSelect(‘combo_’+row_id);
z.enableFilteringmode(‘between’);

from the code, it works perfectly fine.

I placed these lines after the statement

this.cell.firstChild.value=parseInt(this.val); like your answer suggested.

okay placing the code for the combo before the value parsing did do it.
Stupid me :blush:

but I got another problem. I have a string value not an integer one. using parseInt function to parse the value obviously gives me a NaN value.

What other function can I use in place of parseInt?

Aah did it using the getSelectedValue() function.
Took me ages to figure out but i got there. :wink:

Thanks for all your help.