jQuery UI Widgets Forums Grid Server side rendering

This topic contains 2 replies, has 1 voice, and was last updated by  RedantJ 9 years, 1 month ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Server side rendering #81183

    RedantJ
    Participant

    I have a grid set up with server side data, and I want to change the cell colour to “yellow” if duplicate values are found in two SQL tables.

    I got this far:

    var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties) 
    {
    	var newhtml = defaulthtml;
    	var data = "action=unique&value=" + value + "&column=" + columnfield;
    	$.ajax({
    		type: "POST",
    		url: ".data.asp",
    		data: data,
    		error: function(jqXHR, textStatus, errorThrown)
    		{
    			alert ("err: " + errorThrown);
    		},
    		success: function(data)
    		{
    			if (data == "false") {
    				return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + '; background: #cccc00;">' + value + '</span>';
    			}
    		}
    	});
    	return newhtml;
    			
    }

    This is data.asp:

    varColumn = Request.form("column")
    varValue = Request.form("value")
    	
    strSQL = "SELECT * FROM FooTable WHERE " & varColumn & " ='" & varValue & "'"
    Set rs = Conn.execute(strSQL)
    	
    x = 0
    do until rs.eof
    	x = x + 1
    	rs.movenext
    loop
    
    strSQL = "SELECT * FROM BarTable WHERE " & varColumn & " ='" & varValue & "'"
    Set rs = Conn.execute(strSQL)
    	
    x = 0
    do until rs.eof
    	x = x + 1
    	rs.movenext
    loop
    	
    if x > 1 then
    	response.write "false"
    else
    	response.write "true"
    end if
    response.flush()
    response.end()	

    The .asp file is returning the correct value. The HTML code is not showing up.

    There must be a better way.

    Server side rendering #81185

    RedantJ
    Participant

    I did find one way around the problem:

    I added a boolean column to my JSON on the server end.
    In jqxGrid, test the boolean column: If true, then highlight the cell “yellow”, if false, then don’t highlight.
    It will also help in making validation rules.
    Also this is needed for only one table.

    It’s not the best answer to the problem, but it will do for now.

    Server side rendering #81250

    RedantJ
    Participant

    This is one solution:

    In a situation where you want to test for unique values in a Server Side setting, construct the JSON this way:

    {
    "TotalRows": 4
    },
    {
    "Asset": [
    	{
    		"indexHB":"1",
    		"foo1":"1111",
    		"foo1_b":"true",
    		"foo2":"Mary",
    		"foo2_b":"false",
    		"foo3":"Ford"
    	},
    .
    .
    .

    For the fields foo1_b and foo2_b, test for unique values on the server side, data.asp, like so:

     .
    .
    .
    response.write chr(34) & "foo1_b" & chr(34) & ":"
    
    tempSQL = "SELECT * FROM Foobar WHERE foo1 = '" & value & "'"
    Set rs2 = Conn.execute(tempSQL)
    y = 0
    do until rs2.eof
    	y = y + 1
    	rs2.movenext
    loop
    			
    if y > 1 then
    	response.write chr(34) & "true" & chr(34) & ","
    else
    	response.write chr(34) & "false" & chr(34) & ","
    end if

    Then, using this as a model:

    var cellclass = function (row, columnfield, value) {
    	var value2 = $('#jqxgrid').jqxGrid('getcellvaluebyid', row, columnfield.concat("_b"));
            if (value2 == true) {
                  return 'yellow';
            }
    };
Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.