sagar Jinturkar

sagar Jinturkar

  • NA
  • 214
  • 4.2k

Data bind to table from custom list in Client object model

Apr 25 2018 5:42 AM
$( document ).ready(function() {
$("#txt_EmpID").blur(function(){
getEmpInfo($(this).val());
});
});
function getEmpInfo(empID)
{
alert(empID);
var clientContext = SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('EmployeeInfo');
var query = "<View>"+
"<Query>"+
"<Where>"+
"<Eq>"+
"<FieldRef Name='EmployeeID'/>"+
"<Value Type='Text'>"+empID+"</Value>"+
"</Eq>"+
"</Where>"+
"</Query>"+
"<ViewFields>"+
"<FieldRef Name='ID'/>"+
"<FieldRef Name='EmployeeID'/>"+
"<FieldRef Name='EmployeeName'/>"+
"<FieldRef Name='EmployeeAddress'/>"+
"<FieldRef Name='EmpSalary'/>"+
"<FieldRef Name='EmpEmail'/>"+
"<FieldRef Name='EmpContact'/>"+
"</ViewFields>"+
"</View>";
camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
items = oList.getItems(camlQuery);
clientContext.load(items);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded() {
var empItems = items.getEnumerator();
while (empItems.moveNext())
{
var empItem = empItems.get_current();
var EmpName = empItem.get_item('EmployeeName');
var EmpAdd = empItem.get_item('EmployeeAddress');
var EmpSal = empItem.get_item('EmpSalary');
var EmpEmail = empItem.get_item('EmpEmail');
var EmpContact = empItem.get_item('EmpContact');
alert("Success");
}
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
}

Answers (1)