sharepoint 2013将搜索字段添加到自定义列表视图

问题描述:

嗨!

我使用CSR更改了自定义列表的视图.我需要为此列表在此列表中添加两个搜索字段,但是我不知道该怎么做.

I change the view of the custom list using CSR. I need to add two search fields to this list for this list, but I have no idea how to do this. 

我可以使用CSR或JSOM做到这一点吗?

I can do this with CSR or JSOM?

如何使用JS将新的CAML提交到列表视图Web部件?

How can I submit new CAML to the list view web part using JS?

伊万,

如果要在CAML查询中为列表视图Web部件添加搜索字段,我们可以设置一个新的CAML查询以使用JavaScript客户端对象模型为列表视图包括这两个新字段,例如:

If want to add search field in CAML Query for a List View Web Part, we can set a new CAML Query to including this two new fields for the list view with JavaScript Client Object Model, for example:

function UpdateViewJSOM(){  
    viewContext = SP.ClientContext.get_current();  
    var web = viewContext.get_web();  
    var listCollection = web.get_lists();  
    list = listCollection.getByTitle("Test");  
    viewCollection = list.get_views();  
    view = viewCollection.getByTitle("GridView");  
  
    var camlQuery = new SP.CamlQuery();  
    var query = "<Where><Eq><FieldRef Name='NewColumn1' /><Value Type='Text'>1</Value></Eq></Where>";  
    camlQuery.set_viewXml(query);  
    view.set_viewQuery(camlQuery);  
    view.set_rowLimit(2);  
    view.update();  
    viewContext.load(view);  
  
    viewContext.executeQueryAsync(ViewModified,  
    function onFail(sender,args){  
        console.log(args.get_message());  
    });  
} 

更多信息:

创建,使用SharePoint中的JSOM更新或删除列表视图

谢谢

最好的问候