Thursday, May 27, 2010

JSOM or Excel Service Java Script Model


It's high time to reveal another screte which microsoft is shipping with SPS 2010. For some it may not be screte but I am sure the code snippet is screte for most of the readers. let's jump to topic directly.

The New functionality is Editable excel sheet, which means the user can edit sheet in EWA. more detailed is - developer uses Excel Web Access EWA to render excel sheet in SharePoint, Till MOSS it was just readonly now user can edit the sheet there only. How it is possible?
The developer team introduced another property 'Allow Type and Formula' which is visible from web part properties, once this check box is checked user can edit the sheet right away.

 now why I am so excited about this -> hey it gives us javascript based Object Model to interact with rendered sheet. Ideally what I do is use on content editor web part and assosiate it wih .txt file which contains javascript code.

So below is small snippet about setting selected value using Javascript OM -

function setCellValue(selectedValue)

ewa= Ewa.EwaControl.getInstances().getItem(0); // --get handle of currently rendered workbook

workbook = ewa.getActiveWorkbook(); // handle of active workbook;
rangelocal = workbook.getActiveCell(); //handle of active cell
var column = rangelocal.getColumn(); //
var row = rangelocal.getRow();
var valueArray = new Array(1);
valueArray[0] = new Array(1);
valueArray[0][0] = selectedValue;
function asyncCallbackSet(asyncResult)
lets talk highlighted Text. we will reverse track here, will start from green one.
  • setValuesAsync() is the function responsible for setting range value using async call back.
  • asyncCallbackSet is my call back function,  'SetValue' is context.
  • valueArray this is the 2-Dimensional array contains value for the cell. Now why it is 2 - dimensional as it is excel where cell is row and column, so the first index represents row and second column.
since I just wanted to set value of one cell I my array is of length one but it has to be two -dimension as second dimension represents column value.
asyncResult gives option to trace error using asyncResult.getCode()  and asyncResult.getDescription()
excecute this simple code and feel the power.

worth mentioshing is since SPS 2010 supports silverlight OOB , and communication between Silverlight and Javascript is possible the power is just double :) and this Object model give you control for excel  events like cell changed, tab out etc.
Enjoy :)

Monday, May 17, 2010

SharePoint 2010 Certification


let's wait for new certication from microsoft till then use below information to be ready for first exam :)
70-573 - 12th July 2010
For more about this -
keep waiting :)

Friday, May 14, 2010

XDocument, Creating XDocument Progamatically

Just a simple how to, The code below will let you create XML document in Silverlight.
Silver light does not support XmlDocument, but it gives us XDocument with similar functionalities, which is in System.Xml.Linq.  Below is code -

Object[]  xmlNodes = new Object[5];
xmlNodes[1] = new XElement("Person",new XElement("Name","XX"),new XElement("Age","2"));
xmlNodes[2] = new XElement("Person",new XElement("Name","YY"), new XElement("Age","3"));

XDocument xDoc = new XDocument (new XDeclaration("1.0","utf-16","Yes"),new XElement("Root",xmlNodes);

Wow! done The out put is -
<xml version="1.0" coding="utf-16" standalone="yes">
So what happened actually -
XElement is responsible for creating any node, it takes Node name and value, or object array of values.
XDeclaration is resposible for Xml declaration if
and XDocument is replacement for XmlDocument.
So we create object of XDocument and used Add method to add elements into it.
cheers !!

Tuesday, May 4, 2010

SharePoint 2010 capacity, boundry and limits

The best collection of information -

Left navigation, quick launch, V4.master,create web Page and Team lists

Hi all,
Back to work after 15 days of break :) and below are my recent findings -
There are two ways to create page using UI ->
  • _layouts/spcf.aspx 
  •  siteActions->new web page.
by default the second option (site Actions->new web page) gives you left navigation whereas the first one just gives place holder for content.
So in second one user can get left navigation and quick launch, where as if you start with first approach to get left nav you might be prompted to create subsite, which is wrong. Most of the time people create subsite just to get navigation correctly.
Ideally to get Navigation ->
Site Actions->Site settings->Navigation.
here user will see two options
  • Global Navigation - Ideally the top navigation
  • Current Navigation - Left Navigation
User can create new page and then add them to any navigation area using Add heading and Add links.

In the same excersie I wanted to have link list, team discussion when using Publishing Template for portal,on first glance I didn't find it,
Activate site features 'Team Collaboration Lists' and you will get the all and new type of lists.

so I got required UI without coding and without creating any subsite :)
Try it.