Editor with SharePoint 2013

Editor with SharePoint 2013

rogueldr6rogueldr6 Posts: 8Questions: 2Answers: 0

I am currently using DataTables in SharePoint 2013 for a variety of uses. One of the aspects that has emerged is using it for CRUD operations. I have been able to get a form of CRUD working using DataTables but I know that is more an Editor role. I am thinking about trying Editor out this week during the trial period, but reading the documentation for the various server environments and configuration, I don't think I will be able to implement it. My SharePoint 2013 instance is hosted and the server farm admins have it pretty restricted. I wanted to know if anyone is using Editor within a SharePoint environment and what was required to be successful.

Answers

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    I have seen it done before, but it does take a bit of tinkering. I'm afraid I don't have an out of the box example for you for this. In short, SharePoint has its own CRUD support using REST URLs if I recall correctly? To make Editor work with that, you need to modify how it is sending data to the server. That is done using the ajax option (probably as a function depending on exactly what those URL structures are) or ajax.data if you can just modify the data being submitted.

    Are you able to show me some of the CRUD URLs that your SharePoint app is expecting?

    Allan

  • rogueldr6rogueldr6 Posts: 8Questions: 2Answers: 0

    I switched from ajax to using a js sharepoint library- spRestLib (https://gitbrent.github.io/SpRestLib) to make the url crafting a bit easier to handle. My makeshift CRUD operations with DataTables right now updates a column to the operation (create, read, update, delete), then i use the table to array to output the contents. Lastly the array is run through a for loop and based on the column operation, routes to the appropriate crud operation function. My code environment is isolated, so it's challenging to recreate the code for an example, but the functions generally look like the following:

    sprLib.list('Employees').create({
    Name: column1,
    BadgeNumber: column2,
    HireDt: column3,
    Active: column4
    })

    or

    sprLib.list('Employees').update({
    ID: column5,
    Name:column1,
    Active: column4
    })

    and lastly

    sprLib.list('Employees').delete({ "ID":column5 })

    My makeshift solution with regular DataTables mostly works, but the edits are getting more complicated and the code is getting out of hand. That's why I am looking into Editor.

  • allanallan Posts: 63,237Questions: 1Answers: 10,418 Site admin

    Looks good like that - a nice clean API which looks very similar to Editor's own API.

    I'm not familiar with spRestLib I'm afraid, but what Editor sends to the server and what it expects back is documented here. The ajax option can be specified as a function letting you transform the data it sends and what it gets back before Editor processes it.

    Looking at it, and depending on what you mean but the edits getting more complicated, you might even be able to call the spRestLib methods inside the Editor ajax function.

    When you say there are complicated, in what sense are they getting more complicated?

    Allan

Sign In or Register to comment.