Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all 7589 articles
Browse latest View live

Hide the information when there is no Items in list CSS/JavaScript

$
0
0

Hi Teams,

My Clients want to hide the information when there is no items in the list:

Can this be done with CSS or JavaScript ?

Thanks for any help



Hide any Table header in jquery data table from export to excel

$
0
0

Hide any Table header in jquery data table export to excel 

 

complete:function(data){

      $('#TableID').DataTable( {

        "scrollCollapse": true,
    "paging":   false,
        dom: 'Bfrtip',
        buttons: [
            'copy',
            'csv',
            'excel',
            'pdf',
            {
                extend: 'print',
                text: 'Print all',
                exportOptions: {
                    modifier: {
                        selected: null
                    }
                }
            }
        ],
        select: true
    } );
}

want to hide 1st column in exported excel :

<th class="noExport"> <input type="checkbox" class="AllSelectedTableID"/>Select all</th>


Shiv Sharma

Year wise Total Sum for per user using script editor

$
0
0

Hello,

I have list named as "Credits" which includes column as : User Name, Credits earned, Earned on.

Suppose it contains data as below:

=====================================

User NameCreditsEarned On
Jay1501-Feb-20
Jesper1001-Jan-20
Jay2005-Feb-20
Mads15015-Jan-20
Jay1501-Feb-19
Jesper1001-Jan-19

=====================================

So, I want to display details in web part as follow:

=====================================

Jay = 350

Jesper = 100

Mads = 150

=====================================

Details should be displayed for current year with top ranking person and data should be refreshed whenever new entry added/updated in the list

Can you please guide me if this is possible to achieve using javascript in script editor web part.

Thanking you in advance.

Have a nice day.

Regards,

Jayashri

Powershell script to delete older versions of documents in a SharePoint online library

$
0
0

Sharath Aluri provided this script in a previous post, and it worked perfectly to disable versioning in a SharePoint online (365) library. Thanks so much to Sharath!

Does anyone have any ideas on how to enhance this script by deleting previous versions of all documents (except for the current version) in a given SharePoint online document library? This would likely require a foreach {} loop to loop through each item/file in the library, check its version number, then delete if that number is not equal to the current version.

Thanks!

#Set Parameter
$SiteURL="https://globalsp.sharepoint.com/sites/sharath/disable"
$ListName ="Documents"#Connect to the siteConnect-PnPOnline $SiteURL -UseWebLogin#-Credentials (Get-Credential)#Set versioning settings of the ListSet-PnPList-Identity $ListName -EnableVersioning $False

How to get a value of a lookup field to be populated in a datatable

$
0
0

I have the following script that I am trying to use the results to populate a piechart. However the lookup field called CountTask is preventing the populating of the chart as it is looking for a string(numbers are in that field but in my first test I used the title field so I know that string will work)

How do I output the lookup field value of that item?  Your help is greatly appreciated.

ClientContext context = newClientContext("http://*******/sites/C***C");

                List lstOReq = context.Web.Lists.GetByTitle("EnhancementStatus");

                CamlQuery oquery =newCamlQuery();

                oquery.ViewXml ="<View><RowLimit>100</RowLimit></View>";

                ListItemCollection items = lstOReq.GetItems(oquery);

                context.Load(lstOReq);

                context.Load(items);

                context.ExecuteQuery();

                DataTable otable =newDataTable();

                otable.Columns.Add("Id");

                otable.Columns.Add("Title");

                otable.Columns.Add("CountTask");

               foreach(ListItem iteminitems)

                    otable.Rows.Add(item.Id, item["Title"], item["CountTask"]);

                    AEStatus.DataSource = otable;

                AEStatus.DataBind();

Thank you


IPW

I need to retrieve the IDs and the names of SharePoint groups from a list field using JavaScript and CAML Query

$
0
0
I have a requirement to retrieve listitems from a list where  two fields are people/group fields and I need to retreive the text value as well as the group Id of the SharePoint groups stored in these two fields. How can I achieve it please?

faye fouladi

regarding sPAuditQuery.RestrictToUser()

$
0
0

Hi there,

I would like to use spaudit api to extract some documents behavior logs, if I use the sPAuditQuery.RestrictToUser() method, we need a User ID, such as sPAuditQuery.RestrictToUser(UserID). my question is how I should get user ID? currently, my method is ElevatedWeb.EnsureUser(spusername).ID --> Is it correct?? I use thePeople Picker 

Thanks


Hi there, if you found my comment very helpful then please | Propose as answer | . Thanks and Regards.


Create Pie/Doughnut chart using charts.js and rest api

$
0
0

Hello Techies,

I have a task list with around 5000 items and would like to create a pie / doughnut chart based on task status.

Any idea how to go with it using rest api.

Here are the status values : On Hold, On Track, On Watch, Closed and Troubled

Though I have created bar and line charts using jslink approach:

https://www.linkedin.com/pulse/create-charts-using-chartsjs-highchartsjs-sharepoint-2013-annam/

 


How to increase width of bar Chart

$
0
0

Hi,

I am using chart,kindly let me know to increase its width

My code:

 if (response.d.length > 0) {
            var dataarray = [];
            var datapending = [];
            var datareject = [];
            var datalabel = [];//['Approved', 'Pending', 'Rejected'];
            for (var i = 0; i < response.d.length; i++) {
                console.log(response.d[i].DepartName);
               //  dataarray.push({ name:response.d[i].DepartName + '( ' + response.d[i].totaldocs + ' )', data: [response.d[i].pendingdocs, response.d[i].approveddocs, response.d[i].rejecteddocs] });
                dataarray.push(response.d[i].approveddocs);
                datapending.push(response.d[i].pendingdocs);
                datareject.push(response.d[i].rejecteddocs);
                datalabel.push(response.d[i].DepartName + ' ( ' + response.d[i].totaldocs + ' )');
            }
            new Vue({
                el: '#app',
                components: {
                    apexchart: VueApexCharts,
                },
                data: {
                 //   series: dataarray,
                    series: [{
                        name: 'Approved',
                        data: dataarray
                    }, {
                            name: 'Pending',
                            data: datapending
                        }, {
                            name: 'Rejected',
                            data: datareject
                        }],
                        //}, {
                        //    name: 'Approved',
                        //    data: [{
                        //        x: "A2",
                        //        y: 40
                        //    }]
                        //}, {
                        //    name: 'Pending',
                        //    data: [{
                        //        x: "A2",
                        //        y: 30
                        //    }],
                        //}, {
                        //    name: 'Rejected',
                        //    data: [{
                        //        x: "A2",
                        //        y: 8
                        //    }],
                        //}],
                    chartOptions: {
                        chart: {
                            type: 'bar',
                            height: 350,
                            stacked: true,
                        },
                        plotOptions: {
                            bar: {
                                horizontal: true,
                            },
                        },
                        stroke: {
                            width: 1,
                            colors: ['#fff']
                        },
                        title: {
                            text: 'Publication Grid', align: 'center', style: {
                                fontSize: '14px',
                                fontWeight: 'bold',
                                fontFamily: undefined,
                                color: '#263238'
                            },
                        },
                        xaxis: {
                            categories: datalabel,
                            labels: {
                                formatter: function (val) {
                                    return val + "k"
                                }
                            }
                        },
                        yaxis: {
                            title: {
                                text: 'Departments:'
                            },
                        },
                        tooltip: {
                            y: {
                                formatter: function (val) {
                                    return val + "k"
                                }
                            }
                        },
                        fill: {
                            opacity: 1
                        },
                        legend: {
                            nbsp;                           horizontalAlign: 'center',
                            offsetX: 40
                        }
                    },

                },
            })
        }

Thanks

Changing Title when Adding a Page (Event Receiver)

$
0
0

Hello everyone,

I've just created an Event Receiver as explained on all the sites on the Internet. So I created a new projekt with an Event Receiver for "ItemAdding" on my Page Library inside my Enterprise Wiki. I want to change the Title when a new Page is created. When a new Item gets created he jumps right into my Visual Studio Debugger. So it gets fired! That works fine! But he doesn't change anything! There is no Exception! He just runs over my code but I can't see any changes afterwards. This is the code:

/// <summary>
/// An item is being added.
/// </summary>
public override void ItemAdding(SPItemEventProperties properties)
{
            properties.AfterProperties["Title"] = "test";
            base.ItemAdding(properties);
}

What's wrong here? I really don't know what to do. Thanks!!!
Regards
Chris

copy each of link of a library in c# loop

$
0
0

Hi,

I want to join 3 libraries in a grid-view.

I did it but only texts were copied and pasted in new grid-view. 

Can anybody tell me how can I get link  of each row?  Here is my code:

        protected override void CreateChildControls()
        {
            try
            {
                var list = SPContext.Current.Web.GetList(SPUrlUtility.CombineUrl(SPContext.Current.Web.ServerRelativeUrl, fldListUrl1));

                var gv = new SPGridView();
                gv.AutoGenerateColumns = false;
                gv.EnableViewState = false;

                foreach (string vwfield in list.DefaultView.ViewFields)
                {
                    SPField field = list.Fields.GetFieldByInternalName(vwfield);

                    if (field.Hidden == false)
                    {
                        BoundField boundField = new BoundField();
                        boundField.HeaderText = field.Title;
                        boundField.DataField = field.InternalName;
                        gv.Columns.Add(boundField);
                    }
                }

                var dt = list.GetItems().GetDataTable();
                var list2 = SPContext.Current.Web.GetList(SPUrlUtility.CombineUrl(SPContext.Current.Web.ServerRelativeUrl, fldListUrl2));
                var dt2 = list2.GetItems().GetDataTable();

                foreach (DataRow r in dt2.Rows)
                {
                    var row = dt.NewRow();
                    foreach (DataColumn c in dt.Columns)
                    {
                        row[c.ColumnName] = r[c.ColumnName];
                    }
                    dt.Rows.Add(row);
                }

                gv.DataSource = dt;
                gv.DataBind();
                Controls.Add(gv);
            }
            catch (Exception e)
            {
                Controls.Add(new LiteralControl(e.ToString()));
            }
        }
Thanks for your help

how to set view to filer records based on "sharedby" [me], "sharedby" is my list column

$
0
0

Hi,

I am creating view to show user's record which filter on "sharedby"  column of list, although data is available on list

Problem:

Data is not showed on view when I apply filter on "sharedby" column to show "relevenet user;s" view.

Solution:

how can I apply filter on custom column to show data ( below is image attached )

Thank

Most Recent updates and Most Historic Items in the Library

$
0
0

Hello SP Gurus - In the preparation of migration to the cloud, I need to get the list of Most Recent updated and Most Historic Items from each libraries from each sites. Is there ant tool available or I need to code to get the list?

Thanks & Regards,


Khushi

Enforcing validation

$
0
0
I have a text field that I have to enforce validation. If User tries to enter number first, it should give an error...or if more than 6, it should give an error. . 

Change focus field

$
0
0
On a NewItem.aspx, how can I change focus so that cursor starts at another field instead of the default first field ?

JavaScript dynamic table remove duplicates

$
0
0

I am creating a dynamic table from a SharePoint list and displaying it on a page. the way I am looping through the listitems and finding a match with certain categories which incidentally creates a lot of duplicates. I found the code below to eliminate duplicates:

var seen = {};
          $('table tr').each(function() {
          var txt = $(this).text();
         if (seen[txt])
            $(this).remove();
        else
           seen[txt] = true;
        });

However, what I really need is to eliminate duplicates between two <tr>s with <tr class="content_header">. In other words, I would like to remove all duplicates that fall between two trs  with class="content_header". How can I modify the code above to achieve what I need? the above code removes all duplicates, but I need some duplicates as long as the duplicates are not within two rows with class="content_header" as these rows are my collapsible rows.

Any idea?


faye fouladi


Converting text field to caps

$
0
0
Using Javascript how can I convert text to capitalized letter so that no matter what format user enters, it is always saved in all caps? My field is Single line text. 

The collection was modified. Enumeration operation may not execute.

$
0
0

When I use the code snippet below to delete itemCollection, it will throw error:

The collection was modified.  Enumeration operation may not execute.

Microsoft.SharePoint.Client.ListItemCollection listItems = list.GetItems(camlQuery);
                    clientContext.ExecuteQuery();
                    clientContext.Load(list);
                    clientContext.Load(listItems);
                    clientContext.ExecuteQuery();
                    foreach (Microsoft.SharePoint.Client.ListItem item in listItems)
                    {
                        item.DeleteObject();
                        clientContext.ExecuteQuery();
                    }
What's the right way to delete all items in a collection ?

SPFx web part wih ui fabric modal with iframe show error in IE 11 in all explorer it works ok.

$
0
0

I have a web part with spfx and ui fabric modal that show a image, in ie 11, it shows the error:

[SPLoaderError.loadComponentError]:
**Failed to load component "b86df2da-ab09-4919-b8ac-8cf98bc505eb" (CustomPopUpWebPart). Original error: **Failed to load entry point from component "b86df2da-ab09-4919-b8ac-8cf98bc505eb" (CustomPopUpWebPart). Original error: Unknown error when loading module "b86df2da-ab09-4919-b8ac-8cf98bc505eb_0.0.1"

***INNERERROR:
***Failed to load entry point from component "b86df2da-ab09-4919-b8ac-8cf98bc505eb" (CustomPopUpWebPart). Original error: Unknown error when loading module "b86df2da-ab09-4919-b8ac-8cf98bc505eb_0.0.1"
***CALLSTACK:
Error
   at t._generateErrorStackForIE (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:4:53801)
   at t (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:4:53337)
   at t (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:20:104419)
   at e.buildErrorWithVerboseLog (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:20:114381)
   at e.buildLoadComponentError (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:20:110406)
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:20:100569)
   at Anonymous function (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:1:18051)
   at C (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:1:18027)
   at q (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:1:17872)
   at L (https://spoprod-a.akamaihd.net/files/sp-client/sp-pages-assembly_en-us_5ec6864dd8c7172093e629d6f57b65ef.js:1:17450

Rest -API Library Item Url

$
0
0
$(function () {
             var endPointUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetFolderByServerRelativeUrl('mydocs')/Files?$selelct=Name,File/LinkingUrl&$expand=File";
            var headers = {"accept": "application/json;odata=verbose"
            };
            jQuery.ajax({
                url: endPointUrl,
                type: "GET",
                headers: headers,
                success: function (data) {
                    var _Rows = data.d.results.map(function (a) {
                        var rObj = {};
                        rObj["Name"] = a.Name;
                        rObj["LinkingUrl"] = a.LinkingUrl;
                        return rObj;
                    });
                    new Vue({
                        el: '#adminsSDS',
                        data: {
                            rows: _Rows
                        }
                    });
                }
            })
        });
Not able to get the link right to display it in a page?

Abenet

Viewing all 7589 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>