Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a project and one of the requirement is ti be able to re-order images ot items. So lets say they load the page and i have this 6 images.

1  2
3  4
5  6

and the users would like to swap 1 with 6 etc... Just like you do when ordering colums in the list settings. Or is it possible to use a drag and drop component? Would like to read from anyone who has done something similar. Thanks in Advance

share|improve this question

3 Answers 3

up vote 1 down vote accepted

This open source project does re-ordering using jQuery and the JavaScript Client Object Model - you should be able to adapt it for your needs.

http://sprello.codeplex.com/

The bulk of the code needed to do this is in WebPart.js -

http://sprello.codeplex.com/SourceControl/changeset/view/178c1d245922#SPrelloAssets%2fWebPart.js

Specifically

// If we have an order field to use then work out both what this item's order ID should be
// and update all other items in that column at same time
if (this.OrderField != null) {
    var cards = card.parent().children();
    for (i = 0; i < cards.length; i++) {
        var itemId = $(cards[i]).data("listId");
        if (itemId == mainItemId) {
            mainItemOrder = i + 1;
        }
        else {
            var item = this.List.getItemById(itemId);
            item.set_item(this.OrderField.get_internalName(), i + 1);
            item.update();
        }
    }
}

The rest of the code is for configuring it for different lists - something you may not need so you could do this as just a javascript file with no web part to deploy.

As Alexander mentioned - you're going to have performance problems with large lists, something to think about.

share|improve this answer
    
Thanks guys.SPRello look interesting as it looks as it just uses the orderfield.Will this also work eith Document Lib? –  naijacoder Apr 29 '12 at 5:02
    
Yes - Client Object Model can work with any list type. Just to be clear - this isn't going to 'just do it' for you but will be a good starting point. –  Ryan Apr 30 '12 at 9:00
    
@Ryan, As u said, i have a problem with large lists. I have a function to do reordering using Javascript and the list contains 2000 items. Its damn slow now and need help on how to improve the performance –  user9662 Jul 25 '12 at 6:54

You could check out the CodePlex project "Drag & Drop for SharePoint, that uses jQuery to achieve this: http://spdragdrop.codeplex.com/

share|improve this answer
    
as I understand this project is used for moving files between folders in library, but it does not support reordering. –  Alexander Apr 27 '12 at 8:42

Use javascript on the client side and then sent the http request to the server with the new order. On the server side use SP API to save the new order of the items in the list.

share|improve this answer
    
if there are many items in the library, the reorder operation can take a lot of time to be performed. Thus it makes sense to create button that sould be send order data to the server. Also you can use client object model for this. But the best choise, I think, will be silverlight. –  Alexander Apr 27 '12 at 10:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.