Jump to content
  • 0

Default Values for Inline Insert


TroubleShooter
 Share

Question

Hi, 

 

I've been trying to do a Tabular Report DataPage. However, I can't seem to be able to receive parameters for my fields if they are not hidden. And, the problem with hidden fields is that it hides the whole row which messes-up with my report.

 

I am thinking that a JavaScript solution might come in handy but I am not well-versed in such.

Hoping someone can help out. Many thanks in advance.

 

 

-TroubleShooter

Always causing problems >:D 

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 1

Hi @TroubleShooter,

 

Fortunately,  I might just have the right JavaScript Solution that you need

 I was going to assume that you are referring to the Inline Insert feature but you explicitly stated it in the title of this thread anyway so.... Just follow my lead:

1.) Fire up your DataPage Configuration

2.) Go to Configure Results Page Fields

3.) Add a Header and Footer section. Disable the HTML Editor for your Footer.

4.) Paste the code below and modify as described in the comments. Comments are lines of code usually preceded by two forward slashes '//'

<script>

// Replace [@authfield:name] accordingly with the parameter or custom value you wish.
var paramValue = '[@authfield:name]';


// Replace with the name of your field as described in your DataSource
var field_name = 'TableFieldName';



/* Edits are not necessary for this part */
var i_field = document.querySelector('form[action*="[@cbAppKey]"] #InlineAdd' + field_name);
i_field.value = paramValue;
/* To this part*/


  
//i_field.type = 'hidden'; // If you wish to hide the field as well, just remove the two forward slashes before i_field.type
i_field.readOnly = true;


</script>

 

I really hope this helps. Good luck and happy hacking!

 

Regards,

DN31337

Edited by DefinitelyNot31337
added compatibility for mutiple deployed DataPage on a webpage
Link to comment
Share on other sites

  • 0

Hello @DefinitelyNot31337,

 

I really like your solution!  It is working for one of my datapages and I want to get it to work for a couple other datapages that are deployed on the same page.  I am having an issue on the other datapages keeping the username in.  I think my problems might involve the following:

1. The multiple data pages deployed on the same webpage may be the problem

2. The code needs to be modifed for each specific data page

3. The other data pages also have inline edit/delete which might be affecting it.

I'd like to get this way to work as I like the look and feel of using the inline insert over adding in additional datapages.  Do you know how I can address these problems?

 

Thank you!

Link to comment
Share on other sites

  • 0

Hi @Scott17,

 

Glad you pointed that out ;). You are actually correct about having multiple DataPages deployed on a single WebPage.

 

To fix this, we just need to do a tiny bit of modification in our code.

Just replace the whole line of code that declares i_field with the updated code below.

var i_field = document.querySelector('form[action*="[@cbAppKey]"] #InlineAdd' + field_name);

Do this for all subsequent DataPages and you're good to go.

 

I'm also updating my previous post.

Hope this helps.

 

Regards,

DN31337

Link to comment
Share on other sites

  • 0

I found a way to do it by adding a small function to the javascript to decode html entities:

<script>

function decodeEntities(encodedString) {
    var textArea = document.createElement('textarea');
    textArea.innerHTML = encodedString;
    return textArea.value;
}

// Replace [@authfield:name] accordingly with the parameter or custom value you wish.
var paramValue = '[@XC_Organization]';

// Replace with the name of your field as described in your DataSource
var field_name = 'XC_Organization';

/* Edits are not necessary for this part */
var i_field = document.querySelector('form[action*="[@cbAppKey]"] #InlineAdd' + field_name);
i_field.value = decodeEntities(paramValue);

/* To this part*/

......

 

Link to comment
Share on other sites

  • 0

Hey DN31337,

Would you be able to share a solution if we want to set the default value inline insert as the value from a Search Field (which BTW is a dropdown box,  if relevant)

Under the "Configure Search Fields" page, we tried to use the "On exit, Pass field value as parameter" checkbox and set a [@Customer]

var paramValue = '[@authfield:name]';

We adjusted your above example to:


var paramValue = '[@Customer]';

Unfortunately this was just wishful thinking.. it didnt work.

 

 

Link to comment
Share on other sites

  • 0

just an update:

The above wishful thinking solution works!  you just have to ensure that the destination field,  ie "field_name" in the example above, is NOT a dropdown box.

Once I changed it to a text box it worked.  Note that changing it to a textbox fixed the inline edit thing, but forces the grid edit for this field to a textbox and not a dropdown box.  It essentially disables the dropdown box for this field in grid edit mode... which allows users to enter unvalidated inputs

Link to comment
Share on other sites

  • 0
On 11/17/2019 at 12:23 AM, Elderberg said:

just an update:

The above wishful thinking solution works!  you just have to ensure that the destination field,  ie "field_name" in the example above, is NOT a dropdown box.

Once I changed it to a text box it worked.  Note that changing it to a textbox fixed the inline edit thing, but forces the grid edit for this field to a textbox and not a dropdown box.  It essentially disables the dropdown box for this field in grid edit mode... which allows users to enter unvalidated inputs

 

On 11/17/2019 at 12:27 AM, Elderberg said:

Update #2:

I tried to set the textbox to be non-editable, so that in grid edit mode the users wont be able to make changes, but this breaks the above solution.  So the "Default Value for Inline Edit" is a bit experimental and should be used with caution.

 

Hi @Elderberg,

 

It's true that this solution is experimental. Creating JS customizations for this feature (Inline Edit) is tricky, especially on Cascading Dropdowns. I see a lot of requests regarding that lately. I'm trying to work on it but it's harder than it looks.

 

Anyway, for Dropdown form elements (NOTE: NOT working on Cascading Dropdowns!), I see that it's not working, but simply wrapping the script on a DataPageReady listener does the trick. Here's the code for 'ya.

 

<script>
  
document.addEventListener('DataPageReady', function() {

// Replace [@authfield:name] accordingly with the parameter or custom value you wish.
var paramValue = '[@authfield:name]';


// Replace with the name of your field as described in your DataSource
var field_name = 'TableFieldName';



/* Edits are not necessary for this part */
var i_field = document.querySelector('form[action*="[@cbAppKey]"] #InlineAdd' + field_name);
i_field.value = paramValue;
/* To this part*/


  
//i_field.type = 'hidden'; // If you wish to hide the field as well, just remove the two forward slashes before i_field.type
i_field.readOnly = true;

});
</script>

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...