add new row button - refresh

(3 posts) (2 voices)

Tags:

No tags yet.

  1. eugfri, Member

    hi,

    I was looking for the answer in the demos or forum, but could not find much.

    If i have code like this:

    
       SELECT 'dbr.hidecolumn','ID';
    SELECT 'dbr.javascript', "function confirmdel(obj) {return confirm('Delete lead note \\''+$(obj).parent().children().eq(1).text()+'\\'?');}";
    SELECT 'dbr.report', 'sp_DBR_LeadNotes_del', '[del]', 'hiddendiv', 'inID=ID', 'event=click', 'callbefore=confirmdel';
    SELECT 'dbr.editable', '[Notes]', 'sp_DBR_LeadNotes_edit_note', 'inID=ID','show_link=[NoteType]=="General"','type=autosize';
    SELECT 'dbr.no_data', 'No notes exist for the lead'; SELECT 'General' as NoteType, date(TimeCreated) AS Created, ID, LeadID, Notes, LastUpdateUser, TimeModified, 'dbr.purehtml:<div class="i_delete"></div>' as '[del]' FROM LeadNotes WHERE LeadID=inID; SELECT 'dbr.button', 'ADD NEW NOTE';
    SELECT 'dbr.report', 'sp_DBR_LeadNote_new', 'newnote[]', 'inLogin=(inLogin)', 'inLeadID=(inID)' ;
    SELECT 'dummy result set for the button'; SELECT 'dbr.embed_object', 'hiddendiv';

    In my sp_DBR_LeadNote_new prodedure i do simple insert into LeadNotes table.
    I would like user to immediately see newly added row in resultset above the button. So I have to add "select dbr.refresh;" inside of sp_DBR_LeadNote_new - however, it refreshes the whole report and i dont want that to occur. I would really like to refresh only result set immediately above the "ADD NEW NOTE" button.

    I tried to play with embeds but still no luck.

    How can I achieve this?
    Thank you!

  2. myDBR Team, Key Master

    What you need to do is to return the modified part from sp_DBR_LeadNote_new to the report. To do this:

    Create a procedure that returns the desired content (the table, in this case). It does not need to be a report; a simple procedure will suffice.

    create procedure sp_LeadNotes( inID int )
    begin select 'dbr.title', ''; /* No need for separate title for the table */
    SELECT 'dbr.hidecolumn','ID';
    SELECT 'dbr.report', 'sp_DBR_LeadNotes_del', '[del]', 'hiddendiv', 'inID=ID', 'event=click', 'callbefore=confirmdel';
    SELECT 'dbr.editable', '[Notes]', 'sp_DBR_LeadNotes_edit_note', 'inID=ID','show_link=[NoteType]=="General"','type=autosize';
    SELECT 'dbr.no_data', 'No notes exist for the lead'; SELECT 'General' as NoteType, date(TimeCreated) AS Created, ID, LeadID, Notes, LastUpdateUser, TimeModified, 'dbr.purehtml:<div class="i_delete"></div>' as '[del]' FROM LeadNotes WHERE LeadID=inID; end

    Then, in the main report, call the procedure to display the content inside a DIV with an id. Configure the linked report to return the data to this DIV. The 'no_highlight' class disables the highlight effect when the content is refreshed.

    SELECT 'dbr.javascript', "function confirmdel(obj) {return confirm('Delete lead note \\''+$(obj).parent().children().eq(1).text()+'\\'?');}";
    
    select 'dbr.html', '<div id="leadnotes" class="no_highlight">';
    call sp_LeadNotes( inID );
    select 'dbr.html', '</div>'; SELECT 'dbr.button', 'ADD NEW NOTE';
    SELECT 'dbr.report', 'sp_DBR_LeadNote_new', 'leadnotes', 'inLogin=(inLogin)', 'inLeadID=(inID)' ;
    SELECT 'dummy result set for the button'; SELECT 'dbr.embed_object', 'hiddendiv';

    And finally, in the sp_DBR_LeadNote_new, instead of calling dbr.refrest, call the sp_LeadNotes procedure.

    --
    myDBR Team

  3. eugfri, Member

    great! thank u!


Reply

You must log in to post.