This topic is locked

Auto save on inline add

2/22/2018 4:20:33 PM
ASPRunner.NET General questions
T
Tim author

Hello,
I am using a field event to "auto save" on an add page when a certain field loses focus. I do this in the Client After portion of the field event and use this code:
$("#saveButton1").trigger('click');
It works great on the add page, but now I'd like to implement the same feature while doing an inline add. The "saveButton1" element doesn't exist on the list page while doing an inline add. I inspected the save check mark/button and found it is called "saveLinkX" where X is a session variable, I think. I know from the help file that I can use "var recsId = pageObj.inlineEdit.getRecsId();" to get the list of current ID's on the list page, so I was hoping I could just increment that by 1 to figure out what I needed for the X. But this doesn't work because the number will change if you cancel the add, and then do another inline add.
So is it possible to do an "auto save" on an inline add when you move out of a certain field?
Thanks,

Tim

T
Tim author 2/27/2018

Using this blog post as inspiration I realized that simulating a click of a button inside of a grid row might be very complicated and above my pay grade. Then I realized that, while doing an inline add, there is a "Save All" button. Simulating the click of that is much simpler and works for my situation.
So in the "client after" portion of the field event I just add this:
{$("#saveall_edited1").trigger('click');}
Now the new inline add record saves when I tab out of the field. Pretty cool.
I also have this code in the "JavaScript OnLoad event":
-----------------

pageObj.inlineAdd.inlineAdd();
this.on('afterInlineAdd', function( fieldsData ) {
location.reload();
} )

----------------
Which sets up a new inline add record when the list page loads, then after the "inline add" record is saved, it reloads the page, which sets up another inline add. Makes for quick data entry. I'm sure someone else has figured this out already and there's probably a post out there somewhere, but I couldn't find it.
Thanks,

Tim
P.S. I can't wait for version 10!!!

jadachDevClub member 2/27/2018

I was going to suggest that, but never posted it because I worry that some users may click the inline add multiple times before actually entering data. If they do, all open new adds will save when the first record is checked. I suppose required fields may prevent that, not sure.
Just saying <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=84493&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

T
Tim author 2/28/2018

Thanks Jerry. I figured you had a solution and I was wondering why you were holding out on me. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=84497&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
I get what you say about multiple inline adds, and generally I don't like the system doing things for the user that may not be what they intended, but I have a very specific use case with this one. And I'm setting up an inline add when the page is loaded and I don't even show the user the inline add button, so they can't have multiple open.
Thanks,

Tim

admin 2/28/2018
jadachDevClub member 2/28/2018



I think this is a better solution:

https://xlinesoft.com/blog/2016/01/21/speed-up-data-entry/


Yes, totally forgot that. Thanks.

T
Tim author 3/1/2018

Ah, there's the code to figure out the number at the end of the inline add save button name! And it is way more than I ever would have been to figure out. But I can cut and paste! I'm good at that.
Thanks so much! This is a great solution.
Tim

I
i.NoLim 3/6/2018

Sorry for hijacking your post but this is something I could definitely use in my app.
Would someone mind explaining what exactly is happening in the code? It doesn't seem to be working properly in my app and would like to customize it. "REG FEE," "PASS SUB PCT," "APP FEE," AND "PASS PAID" are automatically filled after a "ACTIVITY" is selected. Unfortunately, the entry is saved after selecting an "ACTIVITY" and tabbing over to "START DATE". I'm not allowed to select a date for "START DATE" or "END DATE" or enter any "NOTES."
I assumed it had to do with

e.keyCode == 9


With '9' being the number of fields there are in your inline add section. I changed it to a different number but my entry was never saved.
Might the error have something to do with the fact that the table I'm trying to do Inline add is a details table of a table that itself is a details table of another table?

I
i.NoLim 3/6/2018

Actually, never mind... this is not going to work for me as I need the whole page to refresh after an Inline Add.
I'm pretty sure I can use it for future projects though. Thank you.

I
i.NoLim 3/6/2018

Actually, never mind... this is not going to work for me as I need the whole page to refresh after an Inline Add.
I'm pretty sure I can use it for future projects though. Thank you.

T
Tim author 3/6/2018

Hi i.NoLim,
Yes, I ended up not using this code also, partly because I also needed the list page to refresh, but also because of other java tasks I needed to perform, and lastly because I (like you) didn't really understand everything that was happening with the code and it made me nervous to have to support that in the future.
I will say, I believe the "e.keyCode == 9" is referring to a "tab" keystroke. I think the other parts of the code tries to figure out how many fields there are, and then determines if you are "tabbing" out of the last field, at which time it saves the record and opens up another inline edit. But I'm really just guessing at this.
The code I had for "clicking" the "Save All" button ended up working great for me. (see my second post). But I had a very specific situation.
Good luck!

Tim

I
i.NoLim 3/6/2018

Thank you for your response timnorvel. I apologize about double posting, not sure what happened there.
Yeah, that's what I was thinking as well but I was not able to figure out how to modify the number of tab keystrokes before it would save the entry.
After rereading your post it seems like it was built for a single table as it automatically opens an "Inline Add" as soon as the "List Page" is loaded. Unfortunately, I'm working with 3 tables. I already have the second part of your code on my app to refresh the "List Page" once an "Inline add" is performed. My issue right now is, as Jadach mentioned, people clicking "Inline add" multiple times and clicking "Save All." The code will only save the last "Inline Add" and completely disregard the others. I think I'm going to end up removing "Inline Add" to prevent "missing" entries.
If anyone knows how to record all entries and then refresh the list page that would be amazing.