Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Delete all records from read only grid

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Delete all records from read only grid

    I have a grid which allows user to import an Excel file. That all works great....but I want to give them the ability to delete all the records of the grid (it is filtered by user)in the event they want to re-import the data.

    I tried this from the documentation....but I can't get it to work



    Code:
    function deleteAllRows() {
    
           var x = {grid.object}._rowsInGrid;
    
           //capture the state of the rowRefrshOnDirty property so that it can be 
           //restored later
    
           var flag = {Grid.object}.rowRefreshOnDirty;
    
           //set the rowRefreshOnDirty property to false so that no ajax callbacks 
           //are made each time a row is set to be dirty
    
           {Grid.object}.rowRefreshOnDirty = false;
           for(var i = 0; i <= x; i++) {
               ele = $('{grid.componentName}.V.R'+i+'.__DELETE');
               $svs(ele,true);
               $e.execute(ele,'change');
           }
    
           {Grid.object}.rowRefreshOnDirty = flag;
    
    }
    Ideally I would want to have an action button perform the delete.

    Any ideas?

    Thanks

    #2
    Re: Delete all records from read only grid

    Anyone?

    Comment


      #3
      Re: Delete all records from read only grid

      Put an action button on the form and make a callback to the server, have the server do the delete and then send a response back to the browser to force the browser to refresh the page. For help writing the xbasic callback, right-click in the xbasic code window and select "Genies... / XBasic Script Genie / SQL (using AlphaDAO) / Execute DELETE Query on a SQL Database". You will probably have to check the code written by the genie and make sure it does not have any user i/o in it as there should be no user interaction when running this server-side. If you are not using sql db then you might have to see if there is another Genie or just write a xbasic loop through record routine from scratch. I can't explain it all here, but maybe a few snippets from my code will help.

      In my case I have a parent grid and a button in each row that the user can click to delete all associate child entries. For me the group of records to be deleted have a parent ID that I get from the parent grid row where the "DELETE" button is clicked from. Your delete button would be in the toolbar instead of on each row. So, how you get the parent ID of records to be deleted will be different than mine. My child records DELETE button, that is declared as a column in the grid, has the following in-line javascript for the OnClick event:

      msgResult = confirm('DELETE all scale value entries for this Rating Scale?');
      if( msgResult ) {
      {grid.Object}.ajaxCallback('G','{Grid.RowNumber}:all','DeleteRateValues','','_getData=true');
      }
      My xbasic server-side "DeleteRateValues" function looks like this:
      function DeleteRateValues as c (e as p)
      dim LocMsg as c = new ""
      LocMsg = ServerDeleteRateValues(e)
      DeleteRateValues = "alert('" + LocMsg + "');"
      end function
      My xbasic "ServerDeleteRateValues" function looks like this:

      function ServerDeleteRateValues as c (e as p)

      dim LocRateScale_SysID as n = new e._currentRowDataNew.rsRateScale_SysID

      'Dim a SQL arguments object, create arguments and set their values
      DIM args as sql::arguments
      if a5_eval_valid_expression("LocRateScale_SysID",local_variables()) then
      args.add("gRateScale_SysID",LocRateScale_SysID)
      else
      ServerDeleteRateValues = "Error: missing argument RateScale_SysID"
      end
      end If

      'DIM a connection variable
      DIM cn as SQL::Connection

      dim flagResult as l
      flagResult = cn.open("::Name::CPTee")
      if flagResult = .f. then
      ServerDeleteRateValues = "Could not connect to database. Error: " + crlf() + cn.CallResult.text
      end
      end if
      cn.PortableSQLEnabled = .t.

      dim LocRowCnt as n = new 0
      dim qs as c = new <<%sql%
      SELECT COUNT(*) FROM dbo.updRateValue WHERE rvRateScale_SysID = :gRateScale_SysID
      %sql%

      flagResult = cn.Execute(qs,args)
      if flagResult = .f.
      ServerDeleteRateValues = "Error counting records to be deleted! Error: " + cn.CallResult.text
      else
      LocRowCnt = convert_type( cn.ResultSet.data(1), "n")
      if LocRowCnt = 0
      ServerDeleteRateValues = "List of Rating Values already empty. Click [Create] button."
      end if
      end if

      if LocRowCnt > 0
      dim qs as c = new <<%sql%
      DELETE FROM dbo.updRateValue WHERE rvRateScale_SysID = :gRateScale_SysID
      %sql%

      flagResult = cn.Execute(qs,args)
      if flagResult = .f.
      ServerDeleteRateValues = "Error deleting records. Error: " + cn.CallResult.text
      else
      ServerDeleteRateValues = "Number records deleted: " + cn.AffectedRows()
      end if
      end if
      cn.close()

      end function
      My code does not include the browser refresh, since I am doing the delete from a parent table. To refresh the browser you would alter my line of code that says

      DeleteRateValues = "alert('" + LocMsg + "');"
      And include another statement besides or in addition to the 'alert' message. Something like, "{grid.Object}.refresh();"

      Comment


        #4
        Re: Delete all records from read only grid

        Rich,

        Thank you so much for the extremely helpful response! I will give it a try.

        Much appreciated!!!

        Comment


          #5
          Re: Delete all records from read only grid

          Hi Rich,

          I'm trying to do something similar, I'm trying to update a record in a read only grid. I'm a little confused as to the locations of the code you laid out. I get that the first part is in the button click but where are in the grid builder are you adding the other two parts?

          As you can probably guess, I'm a noob.

          Comment


            #6
            Re: Delete all records from read only grid

            Jim,
            Use the left-hand panel, in the grid designer on the "Design" tab, and select the "Code / Xbasic Functions" node. The Xbasic functions are declared there. May I suggest videos #66 - User-Defined Ajac callbacks and #85 - Custom Ajax callback. These videos are available from the "Video Finder" option on the "Help" menu.
            Last edited by RichCPT; 12-02-2013, 02:03 PM.

            Comment


              #7
              Re: Delete all records from read only grid

              Thanks for pointing me in the right direction Rich. I'm good to go.

              Comment

              Working...
              X