This article will implement the CAML invocation of JQuery AJAX for the custom fields in SharePoint 2007 in two ways. respectively:
1, the traditional way of writing code, with Fldtypes_ your field type. XML, build custom field types.
2, using Jianyi spcamleditor tool, directly modify the CAML of a list of fields.
The former is highly reusable, and the latter is simple and fast, and you can choose according to your own situation.
We know that you can write client-side code, such as HTML tags, CSS, and JavaScript code, in the schema caml of a field. Thanks to the power of jquery Ajax, we can further process the server-side query asynchronously in field CAML without reloading the page. The combination of the two will certainly enrich the experience of custom fields.
First, let's look at the implementation steps of the traditional coding method:
Create a new project, in this case, we use the class Library project directly. Give it a name:
Copy the Hive directory (which is the structure of C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12, which is what Todd Bleeker says), To place the custom field type. Rename Class1.cs (here for QuickViewField.cs) as needed
We created the XML folder to hold the field definition file Fldtypes_ ..., which will call jquery in this file. We also created Layouts\jquery to store the jquery files. You can download it from the http://jquery.com/.
There are many ways to reference jquery files. You can refer directly to Google, but this approach is not recommended for production environments. You can also store it somewhere under the _layouts, or put it in the Style gallery, and look at the person's liking completely.
In this case, I decided to put it under layouts.
Next, you need to add a strong name to your component.
Now, start writing code for QuickViewFieldType.cs:
public class QuickViewFieldType:SPFieldText
{
public QuickViewFieldType(Microsoft.SharePoint.SPFieldCollection fields, string typeName, string displayName)
: base(fields, typeName, displayName)
{ }
public QuickViewFieldType(SPFieldCollection fields, string fieldName)
: base(fields, fieldName)
{ }
public override void OnAdded(SPAddFieldOptions op)
{
base.OnAdded(op);
this.ShowInDisplayForm = false;
this.ShowInEditForm = false;
this.ShowInNewForm = false;
this.Update(true);
}
}
There are 2 default constructors inside. The onadded override method is to ensure that the field is not displayed in disp/edit/newform.aspx (that is, the list is displayed, edited, new page).