SharePoint REST API填充编辑表单上的单选按钮

时间:2019-06-14 03:59:13

标签: ajax sharepoint-2013 sharepoint-rest-api

使用SharePoint REST API的自定义引导表单具有文本字段,复选框和单选按钮。从单选按钮发布值有效,值被发布到单行文本列中。但是,在我的编辑表单中,单选按钮未显示为选中状态,文本字段正确显示了数据(甚至还没有尝试过复选框)。

$ajaxjj({
async:true,
url:_spPageContextInfo.webAbsoluteUrl + "/api/web/lists/GetByTitle('abc')/GetItemByID(" + value + ")",
method:"GET",
headers: {
"accept": "application/json;odata=verbose",
"content-type":"application/json;odata=verbose"
},
success: function(data) {
console.log(data.d.Title);
$('#FirstName').val(data.d.firstName);
$('input:radio[name="q1"]').val(data.d.question1).prop('checked');

HTML

<div class="custom-control custom-radio">
      <input type="radio" class="custom-control-input qOne" id="q1y" name="q1" value="Yes">
      <label class="custom-control-label" for="q1y">Yes</label>
    </div>   
   <div class="custom-control custom-radio">
      <input type="radio" class="custom-control-input qOne" id="q1n" name="q1" value="No">
      <label class="custom-control-label" for="q1n">No</label>
    </div>

1 个答案:

答案 0 :(得分:0)

想通了。

var dataSet = dataAll; var rows = [], data; for (i = 0; i < dataSet.length; i++) { data = dataSet[i]; rows.push([data.repeaterid, data.callsign]); //your JSON entities here }