Use SharePoint Designer 2010 to implment a fuzzy query for SharePoint 2010 custom list
2012-11-23 17:07
549 查看
This article describes how to use SharePoint Designer 2010 to implment a fuzzy query for SharePoint custom list with with in 10 lines Javascript code.
1. Create a list for testing
![](http://img.my.csdn.net/uploads/201211/23/1353661404_9087.png)
2. Click the
![](http://img.my.csdn.net/uploads/201211/23/1353661496_5226.png)
design in SharePoint designer 2010 button
3. Edit the list view by click the all item view:
![](http://img.my.csdn.net/uploads/201211/23/1353661548_8993.png)
4. Inset two textbox and one button into the list view UI
![](http://img.my.csdn.net/uploads/201211/23/1353661615_4061.png)
5. Paste the follow Javascript into the code view:
![](http://img.my.csdn.net/uploads/201211/23/1353661669_3412.png)
6. Set the parameters (SearchText and MinID)
![](http://img.my.csdn.net/uploads/201211/23/1353661768_7624.png)
7. Set the filters
![](http://img.my.csdn.net/uploads/201211/23/1353661831_7892.png)
you can check the CAML for the filter in the code view of SharePoint designer 2010
![](http://img.my.csdn.net/uploads/201211/23/1353661874_2427.png)
8. Save the list view, and try to use the search function:
![](http://img.my.csdn.net/uploads/201211/23/1353661926_4873.png)
1. Create a list for testing
![](http://img.my.csdn.net/uploads/201211/23/1353661404_9087.png)
2. Click the
![](http://img.my.csdn.net/uploads/201211/23/1353661496_5226.png)
design in SharePoint designer 2010 button
3. Edit the list view by click the all item view:
![](http://img.my.csdn.net/uploads/201211/23/1353661548_8993.png)
4. Inset two textbox and one button into the list view UI
![](http://img.my.csdn.net/uploads/201211/23/1353661615_4061.png)
5. Paste the follow Javascript into the code view:
<SCRIPT type=text/javascript src="http://ajax.microsoft.com/ajax/jquery/jquery-1.7.2.min.js"></SCRIPT> <script type="text/javascript"> String.prototype.endsWith = function(suffix) { return this.indexOf(suffix, this.length - suffix.length) !== -1; }; String.prototype.IsNullEmptyOrSpace = function() { if (this== null) return true; return this.replace(/\s/g, '').length == 0; }; var searchText; var idText; $(document).ready(function () { searchText = GetInputForIdEndWith("TextBox1"); idText = GetInputForIdEndWith("TextBox2"); idText.style.display = 'none'; var searchButton = GetInputForIdEndWith("Button1"); alert(idText.value); searchButton.onclick = function() { if(searchText.value.IsNullEmptyOrSpace()) { idText.value= "0"; } else { idText.value = "32767"; } return true; }; }); function GetInputForIdEndWith(suffix) { return $("input").filter(function() { var id = $(this).attr('id'); if(id) { if(id.endsWith(suffix)) return true; else return false; } else { return false; } })[0]; } </script >
![](http://img.my.csdn.net/uploads/201211/23/1353661669_3412.png)
6. Set the parameters (SearchText and MinID)
![](http://img.my.csdn.net/uploads/201211/23/1353661768_7624.png)
7. Set the filters
![](http://img.my.csdn.net/uploads/201211/23/1353661831_7892.png)
you can check the CAML for the filter in the code view of SharePoint designer 2010
![](http://img.my.csdn.net/uploads/201211/23/1353661874_2427.png)
8. Save the list view, and try to use the search function:
![](http://img.my.csdn.net/uploads/201211/23/1353661926_4873.png)
相关文章推荐
- Use Microsoft SharePoint Designer 2010 to customize the list view 1
- Use Microsoft SharePoint Designer 2010 to customize the list view 3---Parameter and Filter
- Use Microsoft SharePoint Designer 2010 to customize the list view 2
- How to: Add SharePoint 2010 Search Web Parts to Web Part Gallery for Upgraded Site Collections
- How to redirect to a Custom Page for Event Receiver in SharePoint 2010
- Adding Custom Actions to the List Item Menu in SharePoint 2010 Using SharePoint Designer 2010[Sharepoint中添加自定义菜单]
- How to use document library in Sharepoint 2010
- How to tune SharePoint 2010 Server for better performance?
- SharePoint 2010 – The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more inform
- How to Create Multilingual Webpart in SharePoint 2010? Use Localization in Globalization.
- Step By Step Guide to configure the “Replicating directory changes” for SharePoint 2010 and 2013
- Enable SharePoint Designer for Project Web App PWA 2010
- SharePoint designer 2010编辑List的表单时出现错误:soap:Server was unable to process request. ---> Value does not fall within the expected range
- SharePoint 2010: Create a Custom Page Layout for a Publishing Site using SharePoint Designer
- [转]How to Integrate SharePoint 2010 with Reporting Services
- FAST SEARCH FOR SHAREPOINT 2010 特点
- Enable Version Control for SharePoint 2010 Document Libraries
- 以脱机模式运行系统必备组件安装程序 (FAST Search Server 2010 for SharePoint)
- Configure Send To connections in SharePoint 2010
- SharePoint Designer 2010的新增功能【】