jQWidgets Forums

Forum Replies Created

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • in reply to: Additional help needed Additional help needed #85792

    jschultz0614
    Participant

    Histro… You mention .DataBind() but you did not include it in the demo and your API documentation for the grid does not have this method. Where EXACTLY does it go?

    in reply to: Pass parameters to JQXGrid Pass parameters to JQXGrid #85699

    jschultz0614
    Participant

    OK,… I have more than one grid on this page. I need to update all grids either at once or in sequence. Each grid uses an ajax API call. After the grids are updated, the script selects the newly created account. My issue is the grid updates. is there a way to do this with out going to ES7 async/await functions?


    jschultz0614
    Participant

    I have found a work around until a function is developed:

    function GetRowIDOfItemByGUID(GridName, GuidID, DataField)
    {
    var _Object = $(“#” + GridName);
    var dataInformation = $(_Object).jqxGrid(‘getdatainformation’);
    for (i = 0; i < dataInformation.rowscount; i++)
    {
    if($(_Object).jqxGrid(‘getcellvalue’, i, DataField) == GuidID)
    {
    return i;
    }
    }
    return null;
    }

    and from the main page (this is in razor syntax):

    var rowIndex = GetRowIDOfItemByGUID(“jqxDefaultDiscountAccountDropdownGrid”, @Html.Raw(string.Format(“\”{0}\””, PayingBills_DefaultDiscountAccount.ToString())), “AccountIndex”);
    $(“#jqxDefaultDiscountAccountDropdownGrid”).jqxGrid(‘selectrow’, rowIndex);


    jschultz0614
    Participant

    One last thing…. These are GUIDs not INT32 so how do I select a row if the rowid is unknown?


    jschultz0614
    Participant

    OK,… I just realized that my grid name is not the one supplied in the previous posting. I changed the id to the correct id and now Im getting an error stating: Cannot read property ‘{prop}’ of undefined. I also just realized that I have a set reusable functions for my grids and in one of those functions, I have a bound setting for the selectrow event. Unfortunately, the script is not able to work because the “Object” name is not being passed to the sub function.


    jschultz0614
    Participant

    This is what I have so far:

    var rowIndex = $("#jqxDefaultDiscountAccountDropdownWidget").jqxGrid('getrowboundindexbyid', @Html.Raw(string.Format("\"{0}\"", PayingBills_DefaultDiscountAccount.ToString())));
    
    

    $(“#jqxDefaultDiscountAccountDropdownWidget”).jqxGrid(‘selectrow’, rowIndex);

    which translates to the following at render time:

    var rowIndex = $("#jqxDefaultDiscountAccountDropdownWidget").jqxGrid('getrowboundindexbyid', "7c98652e-7941-e611-9c47-c86000a214e4");
    

    $(“#jqxDefaultDiscountAccountDropdownWidget”).jqxGrid(‘selectrow’, rowIndex);


    jschultz0614
    Participant

    OK,… I think this is a start, however, I do not believe that my grid has a bound index. How do I set this?


    jschultz0614
    Participant

    Currently, all the data in the list is unique by its ID which is a GUID. I need to be able to select the row where the GUID is a certain value.


    jschultz0614
    Participant

    jschultz0614
    Participant

    found the answer, all I need to do is check to see if the AddItem column is undefined and that did the trick:

    if($.type(row.UOMRelatedUnit_AddItem) !== "undefined")


    jschultz0614
    Participant

    @ivailo, Ive got a working grid with checkboxes, however I can only select two checkboxes when there are 10 rows. What am I doing wrong?

    function UOMCountEachMulticolumn(){
    		// Start Multicolumn for Unit Of Measure for Count -> Each
    		// prepare the data
    
    		var GenerateUOMCountEachMulticolumnRow = function (i) {
    			var newRow = {};
    			newRow["UOMCountEachIndex"] = '';
    			newRow["UOMCountEachAddItem"] = F;
    			newRow["UOMCountEachName"] = '';
    			newRow["UOMCountEachAbbreviation"] = '';
    			newRow["UOMCountEachConversion"] = '';
    			return row;
    		}
    
    		var data = new Array();
    
    		var jqxUOMCountEachIndex = [""];
    		var jqxUOMCountEachName = [""];
    		var jqxUOMCountEachAbbreviation = [""];
    		var jqxUOMCountEachConversion = [""];
    		var jqxUOMCountEachAddItem = F;
    
    		if(@(Html.Raw(JsonConvert.SerializeObject(ViewBag.jqxUOMCountEachIndex))) !== null){
    			var jqxUOMCountEachIndex = [@(Html.Raw(JsonConvert.SerializeObject(ViewBag.jqxUOMCountEachIndex)))];
    			var jqxUOMCountEachName = [@(Html.Raw(JsonConvert.SerializeObject(ViewBag.jqxUOMCountEachName)))];
    			var jqxUOMCountEachAbbreviation = [@(Html.Raw(JsonConvert.SerializeObject(ViewBag.jqxUOMCountEachAbbreviation)))];
    			var jqxUOMCountEachConversion = [@(Html.Raw(JsonConvert.SerializeObject(ViewBag.jqxUOMCountEachConversion)))];
    		};
    
    		for (var i = 0; i < jqxUOMCountEachIndex.length; i++) {
    			var row = {};
    			row["UOMCountEachIndex"] = jqxUOMCountEachIndex[i];
    			row["UOMCountEachAddItem"] = jqxUOMCountEachAddItem[i]
    			row["UOMCountEachName"] = jqxUOMCountEachName[i];
    			row["UOMCountEachAbbreviation"] = jqxUOMCountEachAbbreviation[i];
    			row["UOMCountEachConversion"] = jqxUOMCountEachConversion[i];
    			data[i] = row;
    		}
    		var source = { 
    			localdata: data, 
    			datatype: "local",
    			datafields:
    				[
    					{ name: 'UOMCountEachIndex', type: 'string' },
    					{ name: 'UOMCountEachAddItem', type: 'string' },
    					{ name: 'UOMCountEachName', type: 'string' },
    					{ name: 'UOMCountEachAbbreviation', type: 'string' },
    					{ name: 'UOMCountEachConversion', type: 'number' }
    				],
    			addrow: function (rowid, rowdata, position, commit) {
    				commit(T);
    			},
    			updaterow: function (rowid, newdata, commit) {
    				commit(T);
    			}
    		};
    
    		var dataAdapter = new $.jqx.dataAdapter(source);
    
    		$("#jqxUOMCountEachDropdownGrid").jqxGrid({
    			width: 500,
    			height: 200,
    			source: dataAdapter,
    			editable: T,
    			selectionmode: 'row',
    			theme: 'energyblue',
    			showtoolbar: T,
    			rendertoolbar: function (toolbar) {
    				var me = this;
    				var container = $("<div style='margin: 5px;'></div>");
    				toolbar.append(container);
    				container.append('<input id="addrowbutton" type="button" value="Add New Row" />');
    				container.append('<input style="margin-left: 5px;" id="addmultiplerowsbutton" type="button" value="Add Multiple New Rows" />');
    				$("#addrowbutton").jqxButton();
    				$("#addmultiplerowsbutton").jqxButton();
    
    				// create new row.
    				$("#addrowbutton").on('click', function () {
    					$("#jqxUOMCountEachDropdownGrid").jqxGrid('beginupdate');
    					var datarow = GenerateUOMCountEachMulticolumnRow();
    					var commit = $("#jqxUOMCountEachDropdownGrid").jqxGrid('addrow', null, datarow);
    					$("#jqxUOMCountEachDropdownGrid").jqxGrid('endupdate');
    				});
    
    				// create new rows.
    				$("#addmultiplerowsbutton").on('click', function () {
    					$("#jqxUOMCountEachDropdownGrid").jqxGrid('beginupdate');
    					for (var i = 0; i < 10; i++) {
    						var datarow = GenerateUOMCountEachMulticolumnRow();
    						var commit = $("#jqxUOMCountEachDropdownGrid").jqxGrid('addrow', null, datarow);
    					}
    					$("#jqxUOMCountEachDropdownGrid").jqxGrid('endupdate');
    				});
    			},
    			columns: [
    				{ 
    					text: '', 
    					editable: F, 
    					datafield: 'UOMCountEachIndex', 
    					width: 0 
    				},
    				{ 
    					text: 'Add', 
    					datafield: 'UOMCountEachAddItem', 
    					columntype: 'checkbox', 
    					width: 40 
    				},
    				{
    					text: 'Name', 
    					editable: T, 
    					datafield: 'UOMCountEachName', 
    					columntype: 'textbox', 
    					width: 200 
    				},
    				{ 
    					text: 'Abbreviation', 
    					editable: T, 
    					datafield: 'UOMCountEachAbbreviation', 
    					columntype: 'textbox', 
    					width: 100 
    				},
    				{ 
    					text: '# of EA', 
    					editable: T, 
    					datafield: 'UOMCountEachConversion', 
    					columntype: 'textbox', 
    					width: 100 
    				}
    			]
    		});
    
    		$("#jqxUOMCountEachDropdownGrid").bind('cellendedit', function (event) {
    			if (event.args.value){
    				$("#jqxUOMCountEachDropdownGrid").jqxGrid('selectrow', event.args.rowindex);
    			} else {
    				$("#jqxUOMCountEachDropdownGrid").jqxGrid('unselectrow', event.args.rowindex);
    			}
    		});
    
    		// select or unselect rows when the checkbox is checked or unchecked.
    		$("#jqxUOMCountEachDropdownGrid").bind('cellendedit', function (event) {
    			if (event.args.value) {
    				$("#jqxUOMCountEachDropdownGrid").jqxGrid('selectrow', event.args.rowindex);
    			}
    			else {
    				$("#jqxUOMCountEachDropdownGrid").jqxGrid('unselectrow', event.args.rowindex);
    			}
    		});
    		//End Multicolumn for Sales Accounts
    	}

    jschultz0614
    Participant

    thnak you

Viewing 12 posts - 1 through 12 (of 12 total)