Rails 3.0.8
I am able to see the grid and it is populated with my data, but when I try to add new data, update or delete those changes are not carried over to database. Here are snippets of my files:
routes:
resources :qtl_table do
collection do
get ‘search’
get ‘view’
get ‘data’
get ‘dbaction’
end
end
controller:
class QtlTableController < ApplicationController
require “builder”
def index
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @qtls }
end
end
def view
end
def data
@qtls = QtlTable.all()
@xml = Builder::XmlMarkup.new
respond_to do |format|
format.html #data.html.erb
format.xml #data.xml.builder
end
end
def dbaction
@xml = Builder::XmlMarkup.new
#called for all db actions
qtl_name = params[“c0”]
parent_1 = params[“c1”]
parent_2 = params[“c2”]
@mode = params["!nativeeditor_status"]
logger.debug "\nMODE: #{@mode}\n"
@id = params["gr_id"]
logger.debug "\nGRID ID: #{@id}\n"
case @mode
when "inserted"
qtl = QtlTable.new
qtl.QTLName = qtl_name
qtl.Parent_1 = parent_1
qtl.Parent_2 = parent_2
qtl.First_entered = :timestamp
qtl.Last_update = :timestamp
qtl.save!
@tid = qtl.QTLID
when "deleted"
qtl=QtlTable.find(@id)
qtl.destroy
@tid = @id
when "updated"
qtl=QtlTable.find(@id)
qtl.QTLName = qtl_name
qtl.Parent_1 = parent_1
qtl.Parent_2 = parent_2
qtl.save!
@tid = @id
end
respond_to do |format|
format.html
format.xml
end
end
app/views/qtl_table/view.html.erb
View all QTLs
var grid = new dhtmlXGridObject("grid_here"); grid.setImagePath("images"); grid.setHeader("QTL name, Parent 1, Parent 2"); grid.setInitWidths("100,100,*"); grid.init(); grid.load("/qtl_table/data.xml"); <%- logger.debug "\n CREATE NEW DP\n"%>
dp = new dataProcessor("/qtl_table/dbaction.xml/");
dp.init(grid);
</script>
<input type="button" value="Add" onclick="grid.addRow(grid.uid(),'new QTL')">
<input type="button" value="Delete" onclick="grid.deleteSelectedRows()">
app/views/qtl_table/dbaction.xml.builder
xml.instruct! ml, :version=>“1.0”
xml.tag!(“data”) do
xml.tag!(“action”,{ “type” => @mode, “sid” => @id, “tid” => @tid })
end
Thanks