如何在metronic中的可编辑数据表中创建<select>?

时间:2017-01-29 19:12:04

标签: javascript jquery

我需要使用&lt; select&gt;在可编辑的数据表中。 我在metronic主题中使用这个可编辑:链接 这个代码在JS文件中: function editRow(oTable,nRow){         aData = oTable.fnGetData(nRow);         var jqTds = $('&gt; td',nRow);         jqTds [1] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [1] +'”&gt;';         jqTds [2] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [2] +'”&gt;';         jqTds [3] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [3] +'”&gt;';         jqTds [4] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [4] +'”&gt;';         jqTds [5] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [5] +'”&gt;';         jqTds [6] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [6] +'”&gt;';         jqTds [7] .innerHTML ='&lt; input type =“text”class =“form-control input-small”value =“'+ aData [7] +'”&gt;';         jqTds [11] .innerHTML ='&lt; a class =“edit”href =“”&gt; Save&lt; / a&gt;';         jqTds [12] .innerHTML ='&lt; a class =“cancel”href =“”&gt;取消&lt; / a&gt;';     } function saveRow(oTable,nRow){         var jqInputs = $('input',nRow);         oTable.fnUpdate(jqInputs [0] .value,nRow,1,false);         oTable.fnUpdate(jqInputs [1] .value,nRow,2,false);         oTable.fnUpdate(jqInputs [2] .value,nRow,3,false);         oTable.fnUpdate(jqInputs [3] .value,nRow,4,false);         oTable.fnUpdate(jqInputs [4] .value,nRow,5,false);         oTable.fnUpdate(jqInputs [5] .value,nRow,6,false);         oTable.fnUpdate(jqInputs [6] .value,nRow,7,false);         oTable.fnUpdate('&lt; a class =“edit”href =“”&gt; Edit&lt; / a&gt;',nRow,11,false);         oTable.fnUpdate('&lt; a class =“delete”href =“”&gt;&lt; / a&gt;',nRow,12,false);         oTable.fnDraw();     } 如何使用&lt; select&gt;而是&lt; input&gt;在JS文件中? &LT;选择&GT;    &lt; option value =“1”&gt; Men&lt; / option&gt;    &lt; option value =“2”&gt;女性&lt; / option&gt; &LT; /选择&GT;

1 个答案:

答案 0 :(得分:1)

您可以使用#include <iostream> class TestClass{ public: TestClass(int Dimensionality, double* InputArray); // prototype of constructor ~TestClass(void); // prototype of destructor double SumListOfNumbers(void); int Dimensionality; double* ListOfNumbers; }; TestClass::TestClass(int DIM, double* InputArray) { Dimensionality = DIM; std::cout << Dimensionality << "\n"; ListOfNumbers = new double[Dimensionality]; for (int i = 0; i < Dimensionality; ++i) { ListOfNumbers[i] = InputArray[i]; std::cout << ListOfNumbers[i] << ", "; } std::cout << "\n"; }; TestClass::~TestClass(void){ std::cout << "Being Destroyed" << "\n"; }; double TestClass::SumListOfNumbers(void){ double Sum = 0; for (int i = 0; i < Dimensionality; ++i) { Sum += ListOfNumbers[i]; } return Sum; } 更改元素。

innerHTML

将其另存为:

function editRow(oTable, nRow) {  

      jqTds[1].innerHTML = ' <select id="ddltesttype"><option>Tox</option></select>';
      jqTds[2].innerHTML = '<input id="txtcomm" type="text" value="' + aData[4] + '">';
    }