Implementation of SharePoint 2013 site column ordering

sharepoint 2013 list column ordering

SharePoint has column ordering feature to set the position of columns in the list. Using that we can position columns as required – first, second, and so on. This feature can be implemented programmatically as done below.

New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

There can be many ways to implement this, but the one described here is the most efficient and convenient and can be used for many purposes like page ordering, product arrangement in store, etc.

Also, read:
SharePoint 2016 new features

Get column display name and internal name using SharePoint object model

Difference between SharePoint-hosted, auto-hosted and Provider-hosted apps in SharePoint 2013

General steps to follow-

1. Dynamically create dropdown having positions as options

2. ‘Focus’ event triggered will save the previous position of item

3. Choose from dropdown the new value to set

sharepoint 2013 column ordering
sharepoint 2013 column ordering

4. ‘On Change’ event will be fired and will get new position (this.value)

sharepoint 2013 column ordering
sharepoint 2013 column ordering

5. First loop will match the new value in the list and set it to previous one

6. Second loop will update the whole list in dropdown with new positions

Consider an example –

If you need to change the order of pages for particular chapter or book. In a particular book, there are many chapters, and every chapter have various subpages. Now if you need to change their position, from the dropdown having order of all the pages in that chapter, simply select the order where you want to keep the page. At the same time other page will be set to its position same as we do ‘column ordering’ in SharePoint list.

Similarly, for particular chapter and selected parent page there are many subpages, so you can adjust the position of subpages from the corresponding order drop-down.

This will help to arrange pages within a particular chapter and main page easily as swapping is done here. For example – if we set the page at second position to the first position, the page at position one will automatically be set to the second position. Below is the code where dropdowns are created dynamically and on the change of one-page order, its value is swapped with other page order.

Focus event will get the current value of page order and the on change event will change and swap values.

sharepoint 2013 list column ordering
sharepoint 2013 list column ordering

The main implementation here is swapping done on the change of position same as SharePoint column ordering and two events triggered every time you change the value – ‘focus’ event to get previous value before a change and ‘onchange’ event to get new value and perform swapping.

For more visit Advaiya

Check out Best Alternative to InfoPath -> Try Now


(Installation & Features)

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →