If I set user data like this:
grid.setUserData(“”, “name”, “value”);
In the server side(Java servlet class), how can get the user data which I set in client side?Thank you.
If I set user data like this:
grid.setUserData(“”, “name”, “value”);
In the server side(Java servlet class), how can get the user data which I set in client side?Thank you.
You can use
request.getParameter(“name”)
where request is the instance of HttpServletRequest
docs.dhtmlx.com/connector__java_ … ialization
Thank you, but unfortunately,
request.getParameter(“name”)
return null and I could not get the real value.
The main jsp code is below: ()
mygrid = new dhtmlXGridObject('gridbox');
... ...
mygrid.init();
mygrid.setUserData("", "name", "value");
mygrid.setSkin("dhx_skyblue");
mygrid.loadXML("/grid.st");
dp = new dataProcessor("/grid.st");
dp.setUpdateMode("off");
dp.enablePartialDataSend(true);
dp.init(mygrid);
“/grid.st” is url mapping of Java servlet class, but in the server side:
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
System.out.println(request.getParameter("name")); //print null
}
Sorry, it is really a bit more complicated
You need to get the id of record from “ids” parameter, and based on that id - you can access the name parameter
String id = request.getParameter("ids").split(",")[0];
String param = request.getParameter(ids[0]+"_"+"name")
In request data stored as
ids = 123,124,125
123_name = value
...
By the way automatic connector updates will not work with enablePartialDataSend mode
Thanks, I do what you say, and I get the right value.I’m sorry to bother you for one more question, it seems that the setUserData function can only use in grid editing mode. If I want to set custom data in select mode, what should I do?
For example, there are two fields which represent start time and end time in HTML or JSP file, and I want to make a search, the search result of grid is different depend on the value of two fields.
Yep, the userdata is sent only with data saving calls.
In case of data loading, you can inject extra parameters in the main url
It may be just simple as
grid.clearAll();
grid.load("data.jsp?value="+input.value)
or if you are using built-in connector filters, it will look like
grid.xmlFileUrl = "data.jsp?value="+input.value;
Next time when filter fire, it will use this url for data loading