Few Extensions

Nov 10, 2009 at 2:00 PM

Hi

I'm working in SharePoint and I used your SPServices. Sometimes your functions don't have enough options, so I modified some of them and added a few new ones.

"Headers file":

// Extension Function
$.fn.SPServices.SPDisplayRelatedInfoEx = function(options) {

    var opt = $.extend({}, {
        columnName: "", 		// The display name of the parent in the form
        relatedWebURL: "", 		// [Optional] The name of the Web (site) which contains the relationships list
        relatedList: "", 		// The name of the list which contains the additional information
        relatedListColumn: "", 	        // The internal name of the parent column in the related list
        relatedColumns: [], 		// An array of related columns to display
        displayFormat: "table", 	// The format to use in displaying the related information.  Possible values are: "table", "tableOnlyBody".
        headerCSSClass: "ms-vh2", 	// CSS class for the table headers
        rowCSSClass: "ms-vb", 		// CSS class for the table rows
        targetColumnName: ""            // [Optional] The display name field where show result
    }, options);
    ...}
    
$.fn.SPServices.SPLookupAddNewEx = function(options) {

    var opt = $.extend({}, {
        relatedWebURL: "",          // [Optional] The name of the Web (site) which contains the relationships list
        listName: "",               // The name of the list which contains the additional information
        lookupColumn: "", 	    // The display name of the Lookup column
        promptText: "Add new {0}",  // Text to use as prompt + column name
        sourceElements: []          // How elements in source url be used
    }, options);
    ...}

$.fn.SPServices.SPCascadeDropdownsEx = function(options) {

    var opt = $.extend({}, {
        relationshipWebURL: "", 	    // [Optional] The name of the Web (site) which contains the relationships list
        relationshipList: "", 		    // The name of the list which contains the parent/child relationships
        relationshipListParentColumn: "",   // The internal name of the parent column in the relationship list
        relationshipListChildColumn: "",    // The internal name of the child column in the relationship list
        parentColumn: "", 		    // The display name of the parent column in the form
        childColumn: "", 	   	    // The display name of the child column in the form
        autoChoice: "",                     // First - automatically choose first element; OnlyOne - automatically choose element if it's the only one; "" - don't automatically choose anything (default)   
        textChoice: "Choice",               // Text to use as prompt (default "Choice")
        CAMLQueryOptions: "<QueryOptions></QueryOptions>" 
    }, options);
    ...}
 
// NEW Function
$.fn.SPServices.SPCascadeMultiDropdowns = function(options) {
     var opt = $.extend({}, {
        relationshipWebURL: "", 	    // [Optional] The name of the Web (site) which contains the relationships list
        relationshipList: "", 		    // The name of the list which contains the parent/child relationships
        relationshipListFieldType: "0",     // 0 - relationshipList is a list name (default); 1 - relationshipList is the display name of a lookup field in the form; 2 - relationshipList is the display name of an input field in the form; 3 - relationshipList is the display name of a textarea field in the form;  
        relationshipListParentColumn: [],   // The internal name of the parent columns in the relationship list
        relationshipListChildColumn: "",    // The internal name of the child column in the relationship list
        parentColumn: [], 		    // The display name of the parent columns in the form; musi być tyle samo co relationshipListParentColumn
        childColumn: "", 		    // The display name of the child column in the form
        logicalOperations: [],              // The logical operation between parentColumn (CAML Logical Joins)
        autoChoice: "",                     // First - automatically choose first element; OnlyOne - automatically choose element if it's the only one; "" - don't automatically choose anything (default) 
        textChoice: "Choice",               // Text to use as prompt (default "Choice")
        textNoChoice: "Lack of choice",     // Text to use as prompt if not found any elements (default "Lack of choice")
        CAMLQueryOptions: "<QueryOptions></QueryOptions>"
    }, options);
    ...}

$.fn.SPServices.SPDeleteItem = function(options) {

    var opt = $.extend({}, {
        relatedWebURL: "", 	    // [Optional] The name of the Web (site) which contains the relationships list
        listName: "", 		    // The name of the list which contains the additional information
        itemID: "",                 // ID item 
        typeItem: "itemList",       // itemList - list item (default); document - item in document library; folder - folder
        alertError: "0"             // 0 - no alert (default); 1 - alert
    }, options);
    ...}

$.fn.SPServices.SPDisplayRelatedInfoInTextarea = function(options) {
    var opt = $.extend({}, {
        columnName: "", 		// The display name of the parent in the form
        relatedWebURL: "", 		// [Optional] The name of the Web (site) which contains the relationships list
        relatedList: "", 		// The name of the list which contains the additional information
        relatedListColumn: "", 		// The internal name of the parent column in the related list
        relatedColumn: "", 		// An array of related columns to display
        textareaColumnName: ""          // The display name TextArea in the form
    }, options);
    ...}

 

I use all these functions in my implementations for clients.


download

J.

Coordinator
Nov 10, 2009 at 2:10 PM

Great stuff, J!

I will definitely go through all of this and add what makes sense into the library.  I've refactored a good part of the existing code for the upcoming release, so I'll need to figure out how this all fits in.

This is the wonderful thing about community-drive open source projects: we all get to contribute and everyone benefits!

M.