C# 如何使用jquery在网格中加载新列表?
我的jquery是这样的C# 如何使用jquery在网格中加载新列表?,c#,jquery,sql,asp.net-mvc,razor,C#,Jquery,Sql,Asp.net Mvc,Razor,我的jquery是这样的 $(document).ready(function () { $('#NotAllotedStudentsGrid').jtable({ title: 'Allot to Students below', paging: true, pageSize: 5, sorting: true, defaultSorting: 'Name ASC', selecting:
$(document).ready(function () {
$('#NotAllotedStudentsGrid').jtable({
title: 'Allot to Students below',
paging: true,
pageSize: 5,
sorting: true,
defaultSorting: 'Name ASC',
selecting: true, //Enable selecting
multiselect: true, //Allow multiple selecting
selectingCheckboxes: true, //Show checkbo.xes on first column
actions: {
listAction: '@Url.Action("NotAllotedStudentsList")',
//deleteAction: '@Url.Action("DeleteStudent")',
//updateAction: '@Url.Action("UpdateStudent")',
//createAction: '@Url.Action("CreateStudent")'
},
fields: {
UserNo: {
key: true,
create: false,
edit: false,
list: false
},
Name: {
title: 'Name',
width: '15%'
},
Batch: {
title: 'Batch',
},
EmailAddress: {
title: 'Email address',
},
ContactNo: {
title: 'Contact No',
type: 'textarea',
}
}
});
//Load student list from server
$('#NotAllotedStudentsGrid').jtable('load');
//Assign selected students
$('#SearchFor').button().click(function () {
var SearchForValue = $("#NotAllotedStudentsList").val();
var StudentInputTypeValue = $("#InputType").val();
var options = {};
options.type = "POST";
options.url = "/Dashboard/NotAllotedStudentsList/";
options.data = JSON.stringify({ model: { SearchFor: SearchForValue, StudentInputType: StudentInputTypeValue } });
options.dataType = "json";
options.contentType = "application/json";
$.ajax(options);
$('#NotAllotedStudentsGrid').jtable('load');//This shows old list,how to rewrite this?
});
其中,最初显示NotAllotedStudentsGrid列表,我使用SearchForValue限制了NotAllotedStudentsGrid列表。但是,它会显示旧的列表。请告诉我如何加载新列表
我的控制器是这样的
public ActionResult NotAllotedStudentsList(AllotQuestionSet model,int jtStartIndex = 0, int jtPageSize = 0, string jtSorting = null)
{
List<TutorStudentsGridModel> tutorStudentsGridModelList = new List<TutorStudentsGridModel>();
User userDetails = _sessionHelper.Get<User>(KrackemSessionConstants.UserDetails);
StudentResponse studentListResponse = new StudentResponse();
int questionSetNo = Int32.Parse(_sessionHelper.Get<string>(KrackemSessionConstants.QuestionSetNo));
if (model.SearchFor != null && model.StudentInputType == StudentInputType.ContactNo)
{
StudentRequest studentRequest = new StudentRequest
{
TutorUserNo = userDetails.UserNo,
QuestionSetNo = questionSetNo,
InputString = model.SearchFor
};
studentListResponse = _questionSetServiceHelper.GetNotAllottedStudentsByContactNo(studentRequest);
}
foreach (StudentContract studentDetails in studentListResponse.StudentList)
{
TutorStudentsGridModel tutorStudentsGridModel = MappingEngineFactory.GetMappingEngine().Map<StudentContract, TutorStudentsGridModel>(
studentDetails);
tutorStudentsGridModel.Id = studentDetails.UserNo;
tutorStudentsGridModelList.Add(tutorStudentsGridModel);
}
if (jtSorting != null)
tutorStudentsGridModelList = ControllerHelper.SortList(jtSorting, tutorStudentsGridModelList);
tutorStudentsGridModelList = jtPageSize > 0 ? tutorStudentsGridModelList.Skip(jtStartIndex).Take(jtPageSize).ToList() : tutorStudentsGridModelList.ToList();
return Json(new { Result = "OK", Records = tutorStudentsGridModelList, TotalRecordCount = studentListResponse.StudentList.Count() });
}
在您的示例中,您正在进行ajax调用,然后丢弃返回的结果???另外,您的服务器代码是否真的需要一个名为model的具有多个属性的参数?请也显示服务器代码。我有我的控制器方法,比如,发布我的控制器代码。请告诉我如何重写代码。AllotQuestionSet看起来像什么?AllotQuestionSet-模型名称。