Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In order to work with this transaction request,  the code created in DSRequest in the previous article needs to be used. The existing code in RPCManager will need to be refactored. As the transaction request is actually a list of DSRequest objects wrapped with additional information, it is necessary to parse and store the list of DSRequest objects. Then, for each DSRequest object, the execute() method is called (as shown in the previous sample) to get the DSResponse object which will be stored in a list for later use. Once all requests are processed, the DSResponse objects will be used to build and send back the response to the front-end. As a side note, a single DSRequest will also be handled by the same code.

Change the UI

You need to add the save button for the transaction progress.

Code Block
languagejavascript
titleapp/assets/javascript/smartclient_ui.js
isc.ListGrid.create({
    ID: "suppyItem",
    width: 700,
    height: 224, 
    alternateRecordStyles: true,
    dataSource: suppyItem,
    showFilterEditor: true,
    autoFetchData: true,
    dataPageSize: 20,
    canEdit:true,
    canRemoveRecords:true
});
isc.IButton.create({
    top: 250,
    title: "Edit New",
    click: "suppyItem.startEditingNew()"
});

isc.IButton.create({
    top: 250,
    left: 100,
    title: "Save all",
    click: "suppyItem.saveAllEdits()"
});

Change the Gemfile 

The smartclient gem v 0.0.5 supports the transaction progress method of the RPCManager helper class.  You can get the methods from here or you can modify and add another methods after you build the gem from github.

Code Block
languageruby
gem "smartclient", "~> 0.0.5"

Processing the Request in the Controller

You need to request the smartclient json parameter from the post.

Code Block
languageruby
titleapp/controllers/smartclient_controller.rb
def data 
      request = params[:smartclient]
      # set the request parameters
      rpc = RPCManager.new(request, Supplyitem)      
      @result = rpc.processRequest 
      render json: @result
end

By running rails server command, the application will start and a grid fetching and displaying the rows found in the table will be shown. (http://localhost:3000)

Code Block
languagebash
rails s

The complete code for this sample project can be downloaded from github.