M.S M.S - 28 days ago 20
jQuery Question

Get Row Data on click of row

I have used a fuelux library to make a table and below is the code I have for the columns

items = [];
for (var i = 0; i < data.length; i++) {
var item = {
id : i,
action :'<a href="" onclick="editRow()" >Edit</a>|<a href="" onclick="deleteRow()" >Delete</a>' ,
name : data[i].Name,
startRange : data[i].StartRange__c,
endRange : data[i].EndRange__c,
oldRiskGrade : data[i].OldRiskGrade__c,
reportingRiskGrade : data[i].ReportingRiskGrade__c,
approvalType : data[i].ApprovalType__c,
displayValueRiskGrade : data[i].RiskGradeDisplayValue__c
}
items.push(item);
}


now when I click on the edit or delete link I want to get the data for the row clicked and also prevent it to refresh the whole page. Somehow fuelux does not have a proper documentation to get the row data. any help is appreciated.

Answer

pass the id parameter in editrow() and deleterow() to identify the row identity:

   items = [];
      for (var i = 0; i < data.length; i++) {
          var item = {
              id: i,
              action: '<a href="javascript:void(0);" onclick="editRow(' + i + ')" >Edit</a>|<a href="javascript:void(0);" onclick="deleteRow(' + i + ')" >Delete</a>',
              name: data[i].Name,
              startRange: data[i].StartRange__c,
              endRange: data[i].EndRange__c,
              oldRiskGrade: data[i].OldRiskGrade__c,
              reportingRiskGrade: data[i].ReportingRiskGrade__c,
              approvalType: data[i].ApprovalType__c,
              displayValueRiskGrade: data[i].RiskGradeDisplayValue__c
          }
          items.push(item);
      }

On click get the parameter from them and fetch the relevant data from the Item[]

Comments