Can I use dhtmxcombo while dynamically adding row to table

Hi,
On a button click, i’m dynamically adding rows to my table. In my table

i’m using dhtmlxcombo. While adding rows the control id and name value will be automatically incremented through javascript. But i couldnt use this method for incrementing my combo id and name. Can I use dhtmxcombo while dynamically adding row to a table. Will the name and id will be incremented automatically.

My code goes here,

<table id="Group">
<tr>
<td>
<div id="grp_code">
<script>
var itemgrp=new dhtmlXCombo("grp_code","grp_code",275);
itemgrp.enableFilteringMode(true);
itemgrp.loadXML(ItemGroup.jsp);
</script>
</div>
</td>
<td>
<input type="text" name="text1" id="text1" value="">
</td>
</tr>
</table>

My function for adding rows goes here.
function addRow(tableID)
{
var table = document.getElementById(tableID);
var rowCount = table.rows.length;
var next_cnt = Number(document.frmratecard.p_no_of_records.value)+1;
var colCount=table.rows[0].cells.length;
var row=table.insertRow(rowCount);
for(var i=0; i<colCount; i++)
{
var newcell = row.insertCell(i);
newcell.innerHTML = table.rows[0].cells[i].innerHTML;
switch(newcell.childNodes[0].type)
{
case "text":
newcell.childNodes[0].value="";
newcell.childNodes[0].name=newcell.childNodes[0].name+(next_cnt);
newcell.childNodes[0].id=newcell.childNodes[0].id+(next_cnt);
break;
case "select-one":
newcell.childNodes[0].selectedIndex=0;
newcell.childNodes[0].name=newcell.childNodes[0].name+(next_cnt);
newcell.childNodes[0].id=newcell.childNodes[0].id+(next_cnt);
break;
}
}
document.frmratecard.no_of_records.value=next_cnt;
}

<input type="hidden" name="no_of_records" value="1">

On clicking add row button i’m passing the table id.

Textbox and combo are getting generated but Combo is not having values in it. The code in the color for normal select drop down list.

Is there any way where i can dynamically add rows which is having dhtmlxcombo in it?
If so how?
Please help me. My combo data is huge and so for filtering i need to use combo.

Thanks in advance.
Vigneshwarie

Hi,

you may create the combo container dynamically, attach it where you need and set the necessary style. Then you may pass the created object to the dhtmlXCombo constructor.

Sorry Alexandra,
I’ m not getting you. Any example will help me a great.
The object which i’m creating for combo should vary for each row added.
ie. var d = new dhtmlXCombo(parameters);
here “d”, the combo variable should be changed automatically.(or in some way it should get incremented, according to the number of rows added.)

And also the parameter, ie the div id should be incremented.
What i have to do? I was digging for past few days. Then thought of posting, help me!

Thanks,
Vigneshwarie

var comboContainer = document.createElement(“DIV”);
parentContainer.appendChild(comboContainer); /attach combo container to the necessary element/

var combo = new dhtmlXCombo(container,“combo_”+rowCount+"_"+i,200);

Thank you, I was waiting for the reply.
I’ll try this and give my feedback.

Thanks,
vigneshwarie