Dynamically hide vLookup column

Home Forums vLooup for SharePoint Dynamically hide vLookup column

Viewing 5 reply threads
  • Author
    Posts
    • #30717

      Hi Alexander,

      I’m encountering following situation:

      I have a vLookup Column which depends on the selection of a product. The vLookup column has 3 currency columns (CHF, EUR, USD) and I want to dynamically display only one of them depending on the currency selection in the parent.

      Is there a possibility to hide / show vLookup columns dynamically ?

      Thank you very much in advance and BR,
      Chris

    • #30723
      Alexander Bautz
      Keymaster

        It is unfortunately no functionality to dynamically hide columns in vLookup, but if you have the sum in one column you can use custom js to append the correct currency symbol after the number.

        Alexander

      • #30741

        Hi Alexander,

        Thank you for your feedback. Actually I have all 3 prices for each item, but returning the correct one to a [CustomField] doesn’t seem to work, although I get no errors in the code. (see attached Screenshots)

        BR,
        Chris

      • #30753
        Alexander Bautz
        Keymaster

          Hi,
          The way you get the price is not synchronous so you must change it – please post the code you use as text here, and I’ll modify it for you – it is easier that explaining what to do.

          Alexander

        • #30759

          Hi Alexander,

          Here is the code:

          
          
          function returnItemPrice(a, item)
          {
              var id = item.get_item("ID");
              debugger;
              var whr = getFieldValue('W_x00e4_hrung');
              var cc = new SP.ClientContext.get_current();
          	var list = cc.get_web().get_lists().getByTitle('Pakete');
          	var oItem = list.getItemById(id);
          	cc.load(oItem);
          	cc.executeQueryAsync(
          	    function(sender, args) 
          	    {
          	        switch(whr) 
          	        {
          	            case 'EUR': console.log("Returning '"+oItem.get_item('EUR').toString()+"'"); return oItem.get_item('EUR').toString();
          	            case 'CHF': console.log("Returning '"+oItem.get_item('CHF').toString()+"'"); return oItem.get_item('CHF').toString();
          	            case 'USD': console.log("Returning '"+oItem.get_item('USD').toString()+"'"); return oItem.get_item('USD').toString();
          	        }
          	    },
          	    function(sender, args) 
          	    {
          	        console.log("Error getting price");
          	    }
              );
          }

          Thank you in advance and BR,
          Chris

          • #30761
            Alexander Bautz
            Keymaster

              Here is the modified code – please note that I have not tested this code so use the debugger to look at the variables to see that it picks up the correct values:

              function returnItemPrice(a, item) {
                  var id = item.get_item("ID");
                  debugger;
                  var whr = getFieldValue('W_x00e4_hrung');
                  var cc = new SP.ClientContext.get_current();
                  var list = cc.get_web().get_lists().getByTitle('Pakete');
                  var oItem = list.getItemById(id);
                  cc.load(oItem);
                  cc.executeQueryAsync(
                      function (sender, args) {
                          var val = "";
                          switch (whr) {
                              case 'EUR':
                                  val = oItem.get_item('EUR').toString();
                              case 'CHF':
                                  val = oItem.get_item('CHF').toString();
                              case 'USD':
                                  val = oItem.get_item('USD').toString();
                          }
                          console.log("Returning '" + val + "'");
                          // Locate the correct placeholder and replace the value
                          var itemId = oItem.get_item('ID');
                          jQuery("#price_placeholder_" + itemId).html(val);
                      },
                      function (sender, args) {
                          console.log("Error getting price");
                      }
                  );
                  // While the asynchronous function above finishes, return a placeholder
                  return "<span id='price_placeholder_" + id + "'>...</span>";
              }

              Alexander

          • #30763

            Hi Alexander,

            Thank you very much for your help, this worked like a charm 🙂

            Thank you and BR,
            Chris

        Viewing 5 reply threads
        • You must be logged in to reply to this topic.