How to get the difference between two arrays with objects using underscore

I want to get the difference between two arrays i.e. array1 and array2.

Example:

Array1:[{Id:1,name:’ram’,age:10},{Id:2,name:’ram 1′,age:10},{Id:1,name:’ram 2′,age:10}]

Array2 :[{{Id:1,name:’ram 2′,age:10}]

Expected Output should be:[{Id:2,name:’ram 1′,age:10},{Id:1,name:’ram 2′,age:10}]

 

 

Solution : We can achieve this using underscore .

Step 1: We can uniquely differentiate two arrays with “Id” property,so i have plucked the Ids from two arrays using _.pluck and took the difference between this two arrays using _.difference and saved in diff object.

Step 2: Finally we can filter the array 1 with the difference object i.e. diff of the ids we got in step 1.
var diff = _.difference(_.pluck(Array1, “Id”), _.pluck(Array2, “Id”));
var finaldifferenceObject = _.filter(Array1, function (obj) { return diff.indexOf(obj.Id) >= 0; });

Advertisements
Posted in Uncategorized | Leave a comment

Passing ID when clicked on hyperlink from one page to other page as connection string in sahrepoint 2010

I want to pass the selected row’s ID to the other page  when clicked on hyperlink in the List View Web part

Note:   {$ID}  IS IMPORTANT

Image

In the above image you can find “Log Time”  a hyperlink placed using sharepoint designer

Open the sharepoint designer ,

  •    Add a hyperlink

     Image

  •  Navigate url proprty from right side window

Image

   </sp:HyperLink NavigateUrl=”../../SitePages/Log%20Time.aspx?Project={$ID}” > Log Time
   </asp:HyperLink>

 

 

Posted in Uncategorized | Leave a comment

Passing ID when clicked on hyperlink from one page to other page as connection string in sahrepoint 2010

I want to pass the selected row’s ID to the other page  when clicked on hyperlink in the List View Web part

Note:   {$ID}  IS IMPORTANT

Image

In the above image you can find “Log Time”  a hyperlink placed using sharepoint designer

Open the sharepoint designer ,

  •    Add a hyperlink

     Image

  •  Navigate url proprty from right side window

Image

   </sp:HyperLink NavigateUrl=”../../SitePages/Log%20Time.aspx?Project={$ID}” > Log Time
   </asp:HyperLink>

 

 

Posted in Uncategorized | Leave a comment

Cascading drop down in sharepoint 2010

Please follow the link blindly it will help you out for sure..

http://www.c-sharpcorner.com/uploadfile/Roji.Joy/cascading-dropdown-in-share-point-using-jquery/

Posted in Uncategorized | Leave a comment

Attaching master page to aspx page

1)Open the page in sharepoint designer

2)Click on the Style->Attach tab from the ribbon  as follows

3)Match content regions->ok

4)Before materpage

5)After attaching masterpage

Posted in Uncategorized | Leave a comment

Migrating Asp.net web 3.5 application to sharepoint 2010

In this example we migrate a asp.net web application,in which we fetch data using sqlDataSource and bind it to gridview.

Steps:

Steps in Visual studio 2010

Note:.net framework should be 3.5

1)Create a web application “bindData” ,design the web from  say “bindSqlDataSource” with gridview and sqldatasource.

2)Configure sqldatasource and bind the dataSource to gridview.

3)Give the stong name

   i)Project properties=>Signing=>enable the checkbox”Sign the assembly”=>New=>enter the Key File Name=>Disable the checkbox “Protect the key fine name”

4)Copy the assembly and namespace from the Application tab in the project properties.

5)Add security tag to  the Assembly.cs file under properties .

  i)[Assembly:System.Security.AllowPartiallyTrustedCallers]

6)Build the application

7)Copy the connection string from web.config file of web application since,the connection for sqlDataSource wold be in web.config file.

 Steps in sharepoint filesystem 

1)Go to inetpub,wwroot,wss,virtualdirectories,portno,bin

 copy the dll from the bin location of the web application to site bin location.

Web app bin

site bin

2)open the web.config file

  i)Add this tag   under  PageParserPaths=><PageParserPathVirtualPath=/*CompilationMode=AlwaysAllowServerSideScript=trueIncludeSubFolders=true/>

 ii)Add Safecontrol tag:

   <SafeControlAssembly=bindData, Version=1.0.0.0, Culture=neutral,  PublicKeyToken=0ea2c35f98b475b8Namespace=bindDataTypeName=*Safe=TrueAllowRemoteDesigner=True/>

   You can get the public key toke using reflector tool

iii)Add the connection to site web config file from web application’s web.config file

 

Steps in sharepoint designer

1)Open the site in sp designer 2010

2)After opening the site import file  ,  “bindSqlDataSource” form

3)Open the file in advanced mode and remove the code tag from the page directive

4)Preview in browser,

Attaching the masteroage to aspx pages is followed in the next post

Posted in Uncategorized | Leave a comment

Error while converting Migrating ASP.net web application to sharepoint 2010

Image

 

This error is because if we are trying to develop a web application on .net 4.0 framework rather than on 3.5 framework.

Sharepoint 2010 supports .net framewwork 3.5 and lower versions,so change the framework from 4.0 to 3.5 to avoid this error

Posted in Uncategorized | Leave a comment