Editor question(s)

Editor question(s)

transporter_iitransporter_ii Posts: 13Questions: 4Answers: 0

OK, testing out the editor and searching for this for a few hours has gotten me nowhere. I finally got "submit: 'all' to send the values of all the editable fields, which I can view in the postSubmit event.

Is it possible to get the values of non-editable fields and send them along with the editable fields' values? Before testing the Editor, I tried rolling my own inline editing (I came so close to making it work). I could easily get the values of any field in the row.

Also, the reason that I gave up on rolling my own was because I was refreshing the data from the server after an edit/update. Every time an edit/update was done, it would increment by one how many trips it made to the server to update the data. So, after six edit/updates, the next edit would get sent to the server seven times.*

Am I going to run into that with the Editor extension? I kind of like refreshing the data after an edit, because it pretty much guarantees the update made it into the database on the server.

*I did actually fix this issue, but I had two columns that were editable, and it killed editing on the second column when I fixed it on the first. I figured the Editor would probably save me enough time to justify it if it doesn't have this problem.

Thanks,

Answers

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    Is it possible to get the values of non-editable fields and send them along with the editable fields' values?

    Yes, you need to define them as fields though so they have relevance in the form. Use hidden for fields that you want to exist in the form (and thus be submitted), but don't want the end user to see / edit. If you want them to see the values, you can use readonly or field().disable().

    it would increment by one how many trips it made to the server to update the data.

    Sounds like you were binding an event that triggers an submit on every submit action and they just kept adding up.

    Am I going to run into that with the Editor extension?

    No. As you can see here.

    Allan

  • transporter_iitransporter_ii Posts: 13Questions: 4Answers: 0

    What I ran into was this:

    https://datatables.net/forums/discussion/48222/click-function-gets-called-multiple-times

    Also, this was very similar:

    https://stackoverflow.com/questions/45044868/jquery-datatable-on-click-tr-function-fires-multiple-times

    And the suggested solutions did work, sort of. I have two columns with an editable field, and if I fixed one of them, the second column stopped working. If there was only one column with an editable field, the solution in the above link would work for me.

    And I kind of think if I worked on it, I could get it working, but the thought hit me that just licensing the Editor would probably save me a lot of time...and do more than just inline editing.

    But outside of that, my roll-my-own inline editing ended up looking and functioning identically to the Editor. If I swap between the two, the only way I know which is which is how many trips it makes to the server on an update.

    Thanks,

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    but the thought hit me that just licensing the Editor would probably save me a lot of time

    That is the main selling point of Editor. Frankly I think most seasoned Javascript developers could write it, or something like it, given enough time. Or you could save yourself a whole load of hassle and let me do the underlying library stuff and you focus on your app and data :).

    Allan

  • rf1234rf1234 Posts: 3,021Questions: 88Answers: 421

    My business wouldn't have started without Editor and Data Tables. Since I wasn't a "seasoned" JavaScript developer back in 2017, I would have needed to hire a front end developer without Editor and Data Tables. That would have killed my business case - and I would have given up.

    Thanks to Allan my company has been thriving for the last couple of years - and I can still handle all of the development work just by myself.

    Thanks again, Allan!

    Roland

  • kthorngrenkthorngren Posts: 21,483Questions: 26Answers: 4,978
    edited December 2

    Agreed, purchasing Editor at a time when I was just learning Javascript saved a lot of development time. I could now write a good basic client side CRUD app but it would still take a lot of work and is still worth buying the license. And it wouldn't be nearly as well written as Editor :smile:

    Kevin

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    Thank you gents - much appreciated :)

    Allan

  • transporter_iitransporter_ii Posts: 13Questions: 4Answers: 0

    So, I did get the value in that I needed, but I didn't seem to do it the way you suggested.

    The row data had a product ID in it that isn't actually used in the table. I just added it as an Editor field and it added it to the data in the postSubmit event. No hidden or readonly fields in the table. ?

    const editor = new DataTable.Editor({
                    idSrc: 'RowId',
                    fields: [
                        {
                            label: 'Quantity',
                            name: 'Quantity'
                        },
                        {
                            label: 'SalePer',
                            name: 'SalePer'
                        },
                        {                        
                            name: 'ProductId'
                        },
                    ],
                    table: tblCart,
                    formOptions: {
                       inline: {
                            onBlur: 'submit',
                            submit: 'all'
                        }
                    },
                });
    

    Everything is working except one issue, which I think I will open a new question for.

    Thanks,

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    If you are using inline editing only, and there is no way to trigger inline editing on the ProductId, then yes, there would be no need to make it a hidden. There would be no harm in doing so, and you might want to if you were going to use the modal for adding records, but it is up to you.

    Allan

  • transporter_iitransporter_ii Posts: 13Questions: 4Answers: 0

    Or you could save yourself a whole load of hassle and let me do the underlying library stuff and you focus on your app and data

    OK, Asp.net is a running joke now, and everyone hates Webforms, but one of the reasons I really like it is because, working by myself, if someone asked me for a report, I could throw a Gridview on a form and have the page running in production almost before the person got back to their seat. I had all of Microsoft (or Telerik) behind me making everything look presentable. All I had to do was feed the controls data. The backend is what I really like doing anyway.

    DataTables isn't as easy, but it has some similarities in that it isn't just me trying to do everything by myself.

    On the plus side, even if it takes a little longer, the tables look way, way nicer(!), and it gets rid of the laggy server-side postbacks of Asp.net. I think the users like the modern, more responsive look and feel of it, too.

    Good job!

  • allanallan Posts: 63,700Questions: 1Answers: 10,501 Site admin

    Excellent - delighted to hear it worked out well in the end :)

    Allan

Sign In or Register to comment.