Loading ...
Sorry, an error occurred while loading the content.
 

Datatable records (rows) removal problems

Expand Messages
  • George
    Hi all, I am having some problems with the record removing from a datatabl. Please find the code I used for removing a selected record from the datatable.
    Message 1 of 1 , May 9, 2007
      Hi all,

      I am having some problems with the record removing from a datatabl.
      Please find the code I used for removing a selected record from the
      datatable.

      function delRecord() {
      var row = globalDataTable.getSelectedRows()[0];
      var recordset = globalDataTable.getRecordSet();
      var recordid = globalDataTable.getSelectedRecordIds()[0]
      var recDelete = recordset.getRecord(recordid);

      var choice = confirm("Do you really want to delete the
      record?");

      if(choice) {
      for(var i = 0; i < recordset.getLength(); i++) {
      var temprec = recordset.getRecord(i);
      var output = compareRecord(recDelete,temprec);
      if(output == 8) {
      recordset.deleteRecord(i);break;
      }
      }
      globalDataTable.deleteRow(globalDataTable.getRow(i));

      }


      globalDataTable.unselectAllRows();

      return;
      }

      compareRecord is a function in my source code using which I've
      compared the record I want to delete with the records of recordset If
      both records are perfect match then I will get the index of the
      record in the recordset and I can remove that particular record from
      the recordset.

      recordset.deleteRecord(i);

      The above mentioned code supposed to remove the selected record from
      the recordset of the datatable. But the above mentioned code is not
      doing so.

      globalDataTable.deleteRow(globalDataTable.getRow(i));

      The above mentioned code supposed to remove the selected row from the
      datatable and it is working correctly.

      In other words when I select a record in the datatable and press my
      Delete link available in the page then everything seems to be working
      the selected record is being removed from the datatable but If I
      perform a column sort operation then the record that I had just
      removed will be also displayed.

      I don't know why this is happening? I am using YUI 2.2.2

      Another thing if you check the documentation of Recordset there is a
      function that returns the index of the specified record which I've
      tried to use and got some error fired telling that Object doesn't
      support that function :(

      Please guide me to solve these kind of problem in YUI datatable.

      Regards

      George
    Your message has been successfully submitted and would be delivered to recipients shortly.