Welcome to my blog. Here I will try my best to provide as much insight into my Sharepoint creations and whatever other creations I can come up with.
Thursday, May 20, 2010
My First Sharepoint Speaking Event
Today I was able to present at a local SPUG meeting. This was my first event and I think it went well. There was definitely some good feedback and a lot of questions. One of the questions really made me wish I could setup a full environment here at home! I do not have a laptop yet so I had to do the Powerpoint slide show option. My presentation was on creating a custom Edit Control Block for list view pages. I am thinking that I might be able to bring that presentation to my blog and provide more code and really show you what can be done at this level as both a power user and developer. Does that sound like a good idea
Wednesday, February 17, 2010
Creating a Blog Suite as a Feature (Intro)
WHAT EXACTLY IS A BLOG SUITE?
So, I was asked to create a blog-like suite of components that could be added as a feature or series of features to an existing site or subsite. The suite was to have a blog, a contacts list, an events(calendar) list, a quicklinks list, and a component that allows users to submit a future blog topic and allows them to vote on a series of topics to blog next. So this to me is a Blog Suite or as the customers wanted to call it an electronic communications suite. The customer will get their wish ;-)
The customer came prepared in this case with a fully working prototype of the look/feel they wanted in an access database. My job is to create a Sharepoint solution that mimics this access solution. I felt a challenge was coming and it was exciting.
So, I started thinking about what I wanted to do to make this as seamless as possible. Initially I created a blog site using the OOB sharepoint template and looked at some of the things that it does and how it looked. This was not going to work the way the customer wanted and I could not just make it a subsite. However, I could use the Sharepoint Solution Generator tool or the (SPSource) tool to pull out the list schemas of the blog site. Or I could create custom lists in a temp site and do the same thing.
I decided that I needed three lists for the blog part and then a separate list for the contacts, quicklinks, and events sections. So in total there will be 6 lists for this solution. My first task was to decide if I wanted to use list templates as mentioned above or if I wanted to create the lists programmatically. I opted for the latter in this case. I decided that I will create a feature in Visual Studio using the VseWss 1.3 extensions. I will add the feature with a feature receiver and this feature receiver will do most of the work in programmatically creating the lists that I need and adding the fields that I need to make it work. I decided to also add a module that would add a webpart page to the root of the site where the feature is activated. This page is going to have a custom webpart that I will add later.
In my next post on this, I will post my first steps in creating the feature and the lists.
First Test of adding html code
So, I was asked to create a blog-like suite of components that could be added as a feature or series of features to an existing site or subsite. The suite was to have a blog, a contacts list, an events(calendar) list, a quicklinks list, and a component that allows users to submit a future blog topic and allows them to vote on a series of topics to blog next. So this to me is a Blog Suite or as the customers wanted to call it an electronic communications suite. The customer will get their wish ;-)
The customer came prepared in this case with a fully working prototype of the look/feel they wanted in an access database. My job is to create a Sharepoint solution that mimics this access solution. I felt a challenge was coming and it was exciting.
So, I started thinking about what I wanted to do to make this as seamless as possible. Initially I created a blog site using the OOB sharepoint template and looked at some of the things that it does and how it looked. This was not going to work the way the customer wanted and I could not just make it a subsite. However, I could use the Sharepoint Solution Generator tool or the (SPSource) tool to pull out the list schemas of the blog site. Or I could create custom lists in a temp site and do the same thing.
I decided that I needed three lists for the blog part and then a separate list for the contacts, quicklinks, and events sections. So in total there will be 6 lists for this solution. My first task was to decide if I wanted to use list templates as mentioned above or if I wanted to create the lists programmatically. I opted for the latter in this case. I decided that I will create a feature in Visual Studio using the VseWss 1.3 extensions. I will add the feature with a feature receiver and this feature receiver will do most of the work in programmatically creating the lists that I need and adding the fields that I need to make it work. I decided to also add a module that would add a webpart page to the root of the site where the feature is activated. This page is going to have a custom webpart that I will add later.
In my next post on this, I will post my first steps in creating the feature and the lists.
First Test of adding html code
<html> <head> <title>Blogger Code Test</title>
Wednesday, February 10, 2010
jQuery Forms Replacement In Sharepoint (Phase III)
Okay, now it is time for a few updates on what I have been able to do and what my final solution is going to look like including the reasons I chose to go that way.
In the last post on this topic, I talked about building the forms either with a Visual Studio webpart or a Dataform webpart from Sharepoint Designer. I talked some on what I had done on the Visual Studio side and now I will talk about what I did on the other side.
First I again create a webpart page to add the webpart to and for this form I wanted to use it for adding new items to a custom task list that I had created.
So I have a page and the list so I then navigated to the page in Sharepoint and chose to edit the page. This allows me to add a webpart and this when it really hit me to try something different. I added a content editor webpart. This is a very powerful webpart. I then used Sharepoint designer to create the html of a form using standard html controls and pasted those into the source editor of the webpart.
Now I have a page that has controls on it and I changed the location of the javascript to the actual PlaceHolderMain content area of the page. This is the javascript that does all the work for getting the data from Sharepoint or updating the data depending on what I am doing. Again I am using the SPServices jQuery library and it really is neat how fast it is at getting and setting the data. This form was very basic as there were no special controls really. It just had a few text boxes and a couple of select boxes. This works great and is a great way to build small forms for displaying and updating certain pieces of data. I am still working on creating a code with code examples but this may be a few weeks from now.
As I said, this does work and I bet I could even get this to work for inline editing of some items directly in the forms or maybe popup a window that does it. Again very useful and I like it.
Now, for the environment that I work in and the tough restrictions placed on it, there are some things that I really can not do in our production environment. The main thing that we are not allowed to do is connect Sharepoint Designer to the site. This really makes it harder to update things or to build webparts that you do not have to export and import. As I mentioned in an earlier post, we have to provide solution packages and we have to have as much of the solution as possible in the package and we use Visual Studio for this.
With that said, I chose to continue to create the forms using VS by creating a .ascx page that has the server controls on it. Using the VseWSS 1.3 extensions I add a new webpart to my solution and in the code-behind page, I attach the .ascx page and get a handle to all the controls. I also connect up the list to this form and prefill the form with the data. This form of course still renders standard controls and I can still use jQuery to do any updating of the data. This method makes it easier if we need to update the form or change it. I do hope to get some code up here soon, but until then, please let me know if you have any questions or feedback. If something is not clear please let me know!
Saturday, February 6, 2010
jQuery Forms Replacement In Sharepoint (Phase II)
Okay, so in my last piece on this topic I tried to layout several options or paths I could take to accomplish my end goal. At the time, my end goal was to replace my Sharepoint forms with jQuery forms. Over the past few days I have done a lot of experimenting with those options that I had laid out in the previous posts. I will now discuss what I have tried first and then what I think I will try next as another approach. I think I will mainly point out here two things. The main purpose of doing this at all is to avoid all of the postbacks to the server and this particular approach requires replacing the forms with custom forms. With that being said let me begin.
For my first test, I wanted to replace the form that users get to when they go to the My Settings section of SP. This is usually found at the top left where it says Welcome (whomever). This dropdown allows you to get to that option which will take users to the userdisp.aspx page if they have the correct permissions. We decided that users should be allowed to change certain options here and we also had a lot more fields for them to fill out. The two main issues were the fields we did not want them to touch and the annoying normal 2 column format of the form which leads to scrolling. So I needed to replace the form or do a lot of other things to make this happen. I chose to replace the form with a custom form. I did not however replace the application pages, I just made a new page and make the users go to that page instead. Here is how I did that.
(Remember from the earlier post that I have to make this as a solution package in Visual Studio (VS) as that is a requirement for portability to other locations from the customer.)
First, I copied the default.aspx page to a new page called Employees.aspx. I did this mainly because I needed a webpart page to hold my form. This means that I am not solving my popup idea at this time but I am choosing to utilize the real estate of the PlaceHolderMain section of the masterpage. So now I have a page to put my form on.
Now, there were basically at this point 2 options I could take here. One option was to build a custom webpart form and drop it on the page and the other was to create a custom webpart form on the page. I know those seem like the same thing, but the difference is how I create the webpart forms. I can build a .Net webpart in VS which allows an easy path for a code-behind page, or I could create a dataform webpart in Sharepoint Designer (SD). I know how to do both of those options but the first choice I made was to go with the VS option first to see what all I could accomplish with that.
So, yes, this does not sound like jQuery and I do plan on getting to that but I wanted to show you how I get there and what I was able to do.
So, I firstly created my aspx page and now I need a form with controls on it. I did this by creating an ascx user control page that just had a table and the form controls laid out the way I wanted them to be. This meant I could design the form with more columns and make it wider so there was no need to scroll. I also had to provide a cascading dropdown option for the customer so that users could select their organizational structure based on where they worked. This is like a Department, Division, and SubDivision rollup. I decided that this rollup could be done in a single list with the 3 fields tied together. Basically this means that you have an entry for each subdivision including its primary division and department.
Now I have my controls so I needed to have a webpart to put them in. In VS I just added a new webpart to my project and this creates the code-behind class file that I need. I used this file to call the ascx page which is placed into the controltemplates folder of the 12 hive in a subfolder. I now have a form with controls that I can use. This is where the fun starts I hope!
If you are following along this far you may be thinking that I have taken a long approach to this and it does indeed seem to be that way. I just had a feeling that I could do something with this that would be cool. I was right so lets press on. I purposely ensured that I did not have the autopostback option turned on for any of the controls on the form. Using c# I also added onchange events to a couple of dropdown (select) boxes. When an asp dropdown control is rendered in this case, it is rendered as a select html control. The onchange events are stored in the additionalpagehead content section of the Employees.aspx page. The codebehind page will prefill the options from the UserInfo list if they are there. It is already drawing the form so this is a good thing in this case. The Department dropdown box is filled with just the departments and it has the client-side onchange event attached! The event utilizes the SPServices jQuery library to to fill the second dropdown box with the divisions of whatever department is chosen in the first one. This second one also has an event to drive the 3rd select box. The form has a button that also uses the SPServices library to save the data back to the UserInfo list! This is pretty cool and very fast and the page does not refresh! Eureka I say!
One note here is that the SPServices library does have cascade dropdown support that I may utilize in the second approach which I will try next. This means that my next approach will be to user Designer to create my forms to add to the Employees.aspx page. This means that I will get to utilize SP controls and see what I can do with them!
Saturday, January 30, 2010
jQuery Forms Replacement In Sharepoint (Phase I)
In my intro post on this series, I tried to lay the ground work for my approach to replacing my forms with jQuery. I wanted to quickly discuss a few points about why I wanted to do this. I guess one of my main issues for the forms I have is maybe one of the no no's designers often speak of. Many of the forms in the tool that I am currently creating contains about 15 to 20 fields that a user has to fill in. The standard forms in SP render with a two column form that scrolls when the content gets too large. I hate scrolling! I really dislike it if I am filling out a form. This left me with a few choices to make that I would pose to the customer. Do they want a single form with all these fields or perhaps build a wizard-like form system that would break the form into smaller pieces so it could fit in a smaller space. I had also seen what the new SP 2010 forms looked like and thought they were better than before. They also popped up instead of redrawing the whole interface. This is what I want to achieve in this series. The customer was not picky about a single form or a series of smaller forms, and this was good because it leaves the options open a little more. So my first ideas were somewhat valid but then I had a few other ideas that I want to lay out to see what they might be able to do.
1: Create a custom form in an iframe contained in a hidden div.
2: Let Sharepoint create the form in an iframe contained in a hidden div.
3: Use jQuery's ajax functions to create the form and return the content to an iframe contained in a hidden div.
4: Use one of my earlier choices.
I really had to think about this as to me it seems logical that I wanted to ensure that I could control everything and have some particular functionality that the customer wanted. WSS 3 does not support cascading dropdowns out of the box. I have seen some solutions that require setting up lists that the users use to support the drop downs. I did not have to do that on the .Net side so much as I was able to create cascading dropdowns in c sharp just fine. However, I really wanted to avoid as much of that as I could because in this version that requires postbacks which is what I want to avoid. Marc Andersons SPServices jQuery library I mentioned in the intro has a nice cascading dropdowns setup. I like this so I am going to see how it will work for the customer and which option it fits in best.
So, my next phase I think is going to be to mix a few ideas together. I think that I will use SP Designer to draw the forms in a hidden frame and then use jQuery to provide the pieces that are needed to the user in a wizard like approach. This will hopefully allow me to use all of jQuery's tools and keep the choices available at one time to a minimum. I will let you know how this goes in a few days. If you have a better idea then please let me know!!
Thursday, January 28, 2010
jQuery Forms Replacement In Sharepoint (Intro)
First off, let me tell you what this series of posts is going to cover. This first post will lay the ground work for my research on using jQuery to replace my Sharepoint forms. The follow ups will go into more details and hopefully a working example.
I want to start with the thought that I am going to try to make my WSS 3 custom sites have a more 2010 like experience as much as I can. So far, it seems that the new version will be all Ajax based and there will be a lot fewer needs to redraw the whole page or do several postbacks to the server just to get stuff done.
With that said, I do have VS 2008 and I can write custom webparts to replace the standard forms. This does work and I like it. However comma (ha ha) every time I want to get/send information to/from the server this required a postback and the whole page needs to be re-drawn. Now, I will honestly tell you that I have not really researched updatepanels so much and I will do that as part of this series.
However, I still wanted to see what I can do with client side scripting and ajax to see if this is feasible for totally replacing a form. So, the first thing I wanted to find out was the quickest way to draw controls that had data from Sharepoint. Let's say I am creating a new item form. These are the questions that I had to answer:
1: Can I write an html file that had all the form controls?
2: Can I write an aspx page that had all the form controls?
3: Do I want to use asp form controls or basic html controls?
4: Do I need to write server side code or can I really do this completely with client side code?
5: How do I tell Sharepoint to use my new form?
There are other things to consider but these were the ones that I thought of up front. So looking at each one:
1: Can I write an html file that had all the form controls?
-- This really is a combination of 1 and 3 and this was hard to decide. I have a lot of coding experience but I have never tried to create some of the controls I knew I was going to need. Plus, Sharepoint and ASP.NET have a lot of nice controls that are not too hard to use.
2: Can I write an aspx page that had all the form controls?
-- As I had stated earlier, I can create this type of page with the code behind needed to get data from SP. This made me wonder if creating an initial aspx page that provides the controls and initial data would be the best choice as I knew how to do that. More on this later.
3: Do I want to use asp form controls or basic html controls? See 1 and 2
4: Do I need to write server side code or can I really do this completely with client side code?
-- Again, this is a combination of the previous points. Having the option of an initial form that is already populated with dropdowns and other things does make it easy to a point. Doing it completely with client side script is possible but is it really feasible to do so? Again, this is a matter of choice. So far, I have not had a lot of success getting that to work. However, thanks to jQuery this might actually be doable. I will get to more of that in just a bit.
5: How do I tell Sharepoint to use my new form?
-- This is going to require custom coding no matter what I do. One idea I had for that was to use a dataview webpart so that I could add modify the links for the New option to go to my new form. This of course would not be feasible unless I did it for every way a user can get to view of that list. I know how to replace the form in the schema file, but that is really not going to work in this case (please let me know if you can get that to work). I am still researching this part.
So, where have I gotten on my quest? Well, what I have tested so far is I have created an aspx page with code behind to draw asp and sharepoint controls on the page just to see if this would work. On a different aspx page I have an iframe inside a hidden div that uses this page as its source. I actually set the source with javascript but I am not sure if I need to or not. I just have a few dropdowns that get data from a few lists. On a click event from a menu I use a jQuery dialog from the jQueryUI library to popup the hidden div with the iframe. This worked! I also added a function to a button on this popup page to see if I can read the contents of a dropdown and this worked as well. The main stumbling point I have now is that I can not seem to use jQuery to attach a change event to the dropdown. Checking the source it has indeed converted the asp dropdown controls to select elements and I have tried different approaches to get a change event attached but it is not working yet. If you have any ideas please let me know! I am confident that I can get the data into sharepoint once I get the forms right. There is a great jQuery library that I plan to use for this. It can be found at http://spservices.codeplex.com The author Marc did a great job with this! I really want to get to the point where I can use it to get data into a list. I know I can also get data out and I am planning on doing that as a second test to compare against the asp form. Again, if you have any suggestions on attaching a change event to the dropdowns let me know. My plan as I just said is to also use the spservices library if this first test does not work. That is where I am at now and I will post again soon as I get more done (or not :) )
Saturday, January 16, 2010
Workdays Late/Due Counter Excluding Holidays Part 1
This is the first part of a site I had to design in Sharepoint. The customer was in need of a commitment tracking system with a due status that would display the amount of workdays that an item had left until it was due and also would display the amount of workdays it was late based on the original ECD. They also threw a curve ball by wanting to exclude holidays. I had to think about this and I asked them if the holidays would be location/project based as well. This is mainly because we have work all over the world and different holidays may apply. This was indeed what they had hoped to achieve and I felt good knowing that I understood what they wanted. I was a little hesitant to commit that I could do it, but I really thought it should be possible. I came up with the following solution. Keep in mind there may be a different way to do this but this is what I thought would do the job in the time I had to do it in.
Step 1 was to create a blank site definition Sharepoint solution in VS 2008 ( I used VSeWSS 1.3 )
Step 2 was to create the list and add the requested fields including the ECD and Due Status fields.
Step 3 was to add another field that would help me do this. I decided to create a computed field that would just be an empty div element with an id based on the ListItem ID and a small token like dsf. This would make a unique empty div for each item on the page.
Step 4 was to create a calendar list that would be a holiday calendar. I just added a field for project so that the holidays could either be set to a project or all projects. The customer would then be able to add the holidays as normal events and this will be taken into account later.
Step 5 was to actually put all the pieces together. I decided to write a page load event on the pages that displayed this field. Again this is just what I chose to do at the time and I also chose C# as the language. The event basically loops through all the open commitments and checks the current date with the ECD. It determines if the date is before or after today and also checks the project and holiday calendar to see if it needs to remove any days. It also removes weekends! So the loop creates a hidden div with another custom id based on the item and places the divs on the page. This so far does not seem to slow down the system at all. So far so good.
Step 6 was to actually display the data to the users. Again I chose to use script for this but I used javascript in this case. The _SPBodyOnLoad function comes in handy here and I used it to loop through all the divs on the page and move the content from the hidden divs to the empty divs based on the unique divs.
Well, that is the description of my approach. In part 2 I will bring some code to the table so I can show you the real good stuff! (Well, it works at least!)
Subscribe to:
Posts (Atom)