Select to view content in your preferred language

Jquery Datatable create a manual ID field

4308
12
12-02-2016 04:10 PM
by Anonymous User
Not applicable

Hello all,

I would like the user to be able to input an ID (same ID for all selected features) to a table via an input textbox. I keep getting mixed results.

This wont work:

var input;
 $("#tesr").change(function () {
                  console.log($("#tesr").val());
                  input = $("#tesr").val();
              });

$.each(featureSet.features, function (index, value) {
                      row = [];
                      row.push(input);
                      
                      $.each(value.attributes, function (index2, value2) {
                          row.push(value2);
                      });
                      data.push(dojo.clone(row));
                  });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

if it is hard coded then it will work as wanted:

$.each(featureSet.features, function (index, value) {
                      row = [];
                      row.push("22");
                      
                      $.each(value.attributes, function (index2, value2) {
                          row.push(value2);
                      });
                      data.push(dojo.clone(row));
                  });

I am not sure what I am missing. Thanks,

Alex

Tags (1)
0 Kudos
12 Replies
by Anonymous User
Not applicable

Thanks!

0 Kudos
by Anonymous User
Not applicable

Now I am getting this error.

0 Kudos
by Anonymous User
Not applicable

Here was my solution. It seems to solve my problem.

var  testresult, table;

$("#tesr").keyup(function () {
testresult = $("#tesr").val();
});


table = $('#example').DataTable({
"columnDefs": [{
"targets":[0],
"data": null,
"defaultContent": testresult
}]
});
0 Kudos