Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So, I have a Kendo grid. On each row of the grid is a selectbox and that selectbox is populated by data from a query.

I perform an on-click action which executes logic in the database that updates both the data that populates the grid AND data that populates the selectbox(es). I then do a dataSource.read() on a parent grid, then another dataSource.read() on the actual grid I'm talking about, which all works fine, but the data in the selectbox(es) does not update.

How do I make the selectbox(es) update?

Here is the grid. The field that represents the selectbox is "orga_ky":

		$("#organisationGrid").kendoGrid({
			  dataSource: dataSource
			, filterable: false
			, sortable: true
			, reorderable: false
			, columns: [
				  { field: "orga_ky", width: "200px", values: ppa(window.organisations), title: "Organisation" }
				, { field: "from_dt", format: "{0:dd/MM/yyyy}", title:"From" }
				, { field: "until_dt", format: "{0:dd/MM/yyyy}", title:"Until" }
				, { field: "sort_order_nb", title: "Primary", values: window.preferedValues }
				, {
					  field: "peor_ky"
					, title:"Actions"
					, width: "100px"
					, template: $gridWrapper.data('editable') ? kendo.template($("#actTpl").html()) : ''
					, editor: $gridWrapper.data('editable') ? function(container, options) {
						//kendoUI prof 2014.sp2 hard coded update/cancel buttons kendo.grid.js@2148 cannot use commands
						var template = kendo.template($("#editActTpl").html());
						var result = template({});

						container.html(result);
					} : function() {}
					, sortable: false
					, filterable: false
					, menu: false
					, hidden: !$gridWrapper.data('editable')
				}
			]
			, editable: $gridWrapper.data('editable') ? "inline" : "no"
			, dataBound: function (e) {
				if (this.dataSource.total() == 0) {
					var colCount = this.thead.find('th').length;
					var content = $gridWrapper.find('.grid-no-data').length ? $gridWrapper.find('.grid-no-data').html() : '<div style="text-align: center">Sorry, no data was found.</div>';
					$(this.wrapper)
						.find('tbody')
						.append('<tr class="kendo-data-row"><td colspan="' + colCount + '" class="no-data">' + content + '</td></tr>');
				}

				var dataView = this.dataSource.data();

				this.tbody.find('a.k-grid-custom-accept,a.k-grid-custom-reject').on('click', $.proxy(triggerValidateChange, this));

				for(var i = 0; i < dataView.length; i++) {
					highlightChanges(this.tbody.find("tr[data-uid=" + dataView[i].uid + "]"), dataView[i]);
					highlightSoftDeleted(this.tbody.find("tr[data-uid=" + dataView[i].uid + "]"), dataView[i]);
				}
			}
			, detailTemplate: kendo.template($gridWrapper.find('.organisation-change-details').html())
			, detailInit: function(e) {
				var detailRow = e.detailRow;
				detailRow.find('td.k-detail-cell tr td').addClass('old-val');
				detailRow.find('td.k-detail-cell').replaceWith(detailRow.find('td.k-detail-cell tr').html());
			}
		});

Here is the on-click action:

	var processRestoreURL = crudServiceBaseUrl + '?method=restorePerson';
	function restorePerson(id, row){
		if (confirm('#getResource("person.detail.confirmrestore")#')) {
			$.ajax({
				type: 'POST',
				url: processRestoreURL,
				data: {
					PERS_KY: id
				},
				success: function (data){
					// Refresh the datasource so the row updates itself
					$("##list").data("kendoGrid").dataSource.read();
					// Make the Organisation tab reload with the restored data
					$("##organisationGrid").data("kendoGrid").dataSource.read();

					// TO DO
					// Reload the selectbox(es). How do we do that?

				},
				error: function (xhr, textStatus, errorThrown){
					alert("Error while restoring person"+ "\n"+ xhr + "\n"+ textStatus + "\n" + errorThrown);
				}
			});
		}
	}


Can anyone point me in the right direction?
Posted
Updated 24-Jul-15 2:51am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900