Display another list fields in popup and save within single form

Hello @harshp924,

Is the name of the list translated to German?

Please try to connect to a different list. Are you getting the same error message?

Thanks,
I think sharepoint is internally change current view name, so i change view name as "1" and it's work.

Hello @mnikitina,
I am getting this error while save Edit or new Form.

Hello @harshp924,

I'm sorry! Seems it was an issue on our side. Could you please try to save the form again and let me know if you get the same error or not.

Thank you!

Hello @mnikitina,
Yes, it is working fine now,
Can you tell me how can I achieve limitation of Fields that i was trying to enter with 'List or Library' Control,
For example, i have column 'hours' on my list and I want to allow each user can enter only four records in a list, and the total of these four records should be a maximum of 20.

Likewise, 'Hours' for first, second, third, and fours record is 5, so total is 20.
Now user can not enter the fifth record.

Please let me know if you don't get it,

Thanks.

Hello @harshp924,

You can calculate the total by the column. Please see this post for the code sample:

And you can use the below code to disable Add New Item button if the total is greater than or equal to 20:

fd.field('Total').$on('change', function(value){
    if(value >= 20) {
        fd.control('SPDataTable0').buttons[0].disabled = true;
    }
});

Thanks, @mnikitina,

I think it will solve my problem, but is there any way that i can only show data of only current logged in users.
Like when i use list and library control, i can see all data of list, i don't want this, like is there any way that i can only see an entry that added by the current user or i can only see any particular entry that added by user?
I hope you get my point,
Thanks In Advance.
Have a good day.

Hello @harshp924,

You can filter items in List or Library control dynamically. Please see this post from more details:

Hello, @mnikitina
Here is code i am useing and its completely work,
fd.spRendered(function() {
var dt = fd.control('SPDataTable0');
dt.ready().then(function() {
filterDT();
});

//filter List or Library with new value when Search field changes
fd.field('Search').$on('change', function() {
    filterDT();
});

function filterDT(){
    dt.filter = "<Contains><FieldRef Name='Title'/><Value Type='Text'>"
        + fd.field('Search').value + "</Value></Contains>";
    dt.refresh();
}

});

My problem is, it is showing all data even if it contains single latter/word, is there any way that i can check strictly and display only after complete match success.
also, I don't wan's use on change event, can i use some other jquery method for example blur, focusOut, focusIn like?

Also, can we set any value from form's field in List or Library control (list or library control's new item form)?

Hello @harshp924,

You can use Eq comparison operator instead of Contains like this:

dt.filter = "<Eq><FieldRef Name='Title'/><Value Type='Text'>"
        + fd.field('Search').value + "</Value></Eq>";

Hello @mnikitina,
is there any way we can change name of list column for different users language, i don't wont to change any thing in SharePoint list.

image

Hello @harshp924,

You can change the column headers using jQuery. Please see the code sample.

fd.control('SPDataTable1').ready().then(function(dt) {

    var header = $(fd.control('SPDataTable1').$el).find('th');
    //change header
   //3 is a column index
    $(header[3]).html('New header');

});

Thanks, @mnikitina.
Perfectly works for me.

1 Like

Hello @mnikitina,
I'm using list or library control, and filter it with use of CAML query,
My problem is when I open my form, some times it is not filtering the grid, code is as per below,

var dt = fd.control('Contracts');

  dt.ready().then(function () {

    //fd.field('myLogin').disabled = true;

    filterDT();

  });

  //filter List or Library with new value when Search field changes

  fd.field('Mytumlogin').$on('change', function () {

    filterDT();

  });

  function filterDT() {

    dt.filter = "<Contains><FieldRef Name='MyTUMid'/><Value Type='Text'>"

      + fd.field('Mytumlogin').value + "</Value></Contains>";

    dt.refresh();

  }

//disable new item button
fd.field('Mytumlogin').$on('change', function (value) {

                if (value == "") {

                  fd.control('Contracts').buttons[0].disabled = true;

                }

                else {

                  fd.control('Contracts').buttons[0].disabled = false;

                }

              });

This code is completely working, but somehow in some case it shows all data and in console it shows form have no such control to disabled.

I am bit in trouble with of this, bcz it create a security issue, user can easily shows all data from list,

Please look into this, any help will be appreciated.

Thanks.

Hello @harshp924,

Please share the screenshot of the error from the browser console(F12).

Thank you!

Hello @mnikitina,
Here in ss,

Thanks for look into this.

Hello @mnikitina,
Does it seem like list or library control is not ready/load after complete spRender?
i am facing above plus one more problem for that, here i write my code below and attached screenshot,
it is terrible because while i get one error for this, my all forms rules are not working, even the code user above for filter is also not working, as a security and performance, it creates problem.
Please find code below,

    function calcTotal() {

      var value = fd.control('Contracts').widget.dataItems();


      var total = 0;
      if (value) {
        for (var i = 0; i < value.length; i++) {
          if (value[i].MyTUMid == fd.field('Mytumlogin').value) {
            if (value[i].Hours)
              //total += parseInt(value[i].Hours.replace(/[^0-9.]/g, ""));
              //we get number as (comma) , and we have to convert it as . (dot)
              var decimalPoint = value[i].Hours.replace(",", ".");
            total += parseFloat(decimalPoint);
          }
        }
      }
      fd.field('TotalHoursActiveContracts').value = total;


    } 
function filterDT(dt) {

  dt.filter = "<Contains><FieldRef Name='MyTUMid'/><Value Type='Text'>"

    + fd.field('Mytumlogin').value + "</Value></Contains>";

  dt.refresh();

}

    var myVar = setInterval(calcTotal, 2000);
dtContract.ready().then(function (dt) {

    filterDT(dtContract);
});

Above code, I am using to count hours from list or library control and simple filtration.

the error I am getting while using the above code.

Please lookinto this, let me know if there is problem from my end.

Thanks.

Hello @harshp924,

You are calling calcTotal function outside of the ready event. Please try out the following code:

fd.control('Contracts').ready().then(function (dt) {
    var myVar = setInterval(calcTotal, 2000);
});

Thanks @mnikitina,
i was try below and it works...!
function calcTotal() {
fd.control('Contracts').ready().then(function(dt) {
//dt parameter is the same as fd.control('SPDataTable0')
//fd.control('Contracts').refresh();
//fd.control('Contracts')._dataProvider.refresh();
var datalibrary = dt.widget.dataItems();
console.log(datalibrary,"calcTotal");
var total=0;
if(datalibrary){
for(var i=0;i<datalibrary.length;i++){
if(datalibrary[i].Hours){
var decimalPoint = datalibrary[i].Hours.replace(",", ".");
total += parseFloat(decimalPoint);
}
}
console.log(total);
}
fd.field('TotalHoursActiveContracts').value = total;
});
}

I want to know that in spRender method it is good to use more than one Ready event? is it best practice vice ok or not?

Thanks.

Hello @harshp924,

I'm glad its working now!

You can add as many ready events for the control as required by your code.

1 Like