Showing posts with label jQuery. Show all posts
Showing posts with label jQuery. Show all posts

Wednesday, June 19, 2013

Add borders in SharePoint 2007 list view

Sometime we get some requirement to add some styles in SharePoint list views. Yesterday, I got it from CEO that he wants to add lines in between each list item in all lists in his Team Site. I tried to add following CSS style on the page by following Heather Solomon guide but for some reason it was not working for me. http://bit.ly/11mXRAd

/*Set border for every row */
.ms-listviewtable > tbody > tr td{
border-bottom: 1px solid #AFAFAF !important; /* !important needed over override SharePoint inline style */
}
 




Initially sample list was look like this.
 

image
 

I added few lines of jQuery on the page and it started look like this.
 

image
 

Following is the code I used to do this.

 

<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">

$(document).ready(function(){
$("td:empty").html('&nbsp;');

var $listView = $('.ms-listviewtable .ms-vb2 ');
$listView.attr( 'style', 'border-bottom: 1px solid black !important');

var $listView1 = $('.ms-listviewtable .ms-vb-title');
$listView1.attr( 'style', 'border-bottom: 1px solid black!important');

var $listViewTable = $('.ms-listviewtable');

$listViewTable.attr('style', 'border-collapse: collapse !important');

});
</script>

Tuesday, June 7, 2011

Execute code after Asynchronous postbacks

When we use ASP.NET UpdatePanel in our application and do postbacks, it results asynchronous postbacks from controls inside UpdatePanel which don’t trigger window.load() or jQuery’s $(document).ready() methods. To run a method after asynchronous postback, we need to use Sys.WebForms.PageRequestManager. It has add_endRequest() method which allows to attach method to this event which will run after asynchronous postbacks.
To do this, add these lines in your javascript code.
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(loadText);

function loadText() {

// Add your code which will run after Asynchronous postback.

}

If you are doing something on window.load() or $(document).ready() event and want to execute it after postbacks from controls residing inside UpdatePanel, copy that in your asynchronous postback event handler(s) as well.

For attaching a method with Page Load event, we can use

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(eventHandler);