51124

Dojo Datagrid Sort after adding New Item to Store

I'm having an issue with a DataGrid not resorting itself after calling newItem() then save() on the store backing the datagrid.

<div dojoType="dojo.data.ItemFileWriteStore" url="/MultiRaterManagerAjax" id="mrWriteStore" jsId="mrWriteStore"</div> <table dojoType="dojox.grid.DataGrid" region="left" query="{ hasSub: false }" clientSort="true" selectionMode="single" jsId="ldrSubGrid" sortInfo="1" errorMessage="Loading..." store="mrWriteStore"> <thead> <tr> <th width="100%" field="_item" formatter="formatSubs">Subs</th> </tr> </thead> </table>

An event handler calls the following javascript

item = mrWriteStore.newItem({}); //set the necessary attributes on item mrWriteStore.save({onComplete:afterStoreUpdate, onError: saveFailed});

A new item is added to the store, and the DataGrid is updated showing the new item. But the new item is at the bottom of the list. It doesn't seem to recognize the sorting order of the datagrid.

I'm thinking there is an event I need to connect to (or subscribe to) on the datagrid which tells me it has updated the data. Then I call sort/filter functions when this event is fired. But what to connect/subscribe to?

Answer1:

I was struggling with this the other day. I think you need to call the sort() method of the datagrid from inside of your onComplete function, which you have named afterStoreUpdate

dijit.byId('ldrSubGrid').sort();

Recommend

  • Setting a custom Content-Range Header using Restlet
  • Dynamically injected dojo widget not parsed in IE8
  • How to apply standby.show to the full body of html
  • dojo: which events are attached to an element?
  • Set datagrid to show just 5 rows per page
  • WPF auto resize elements
  • jqGrid setting zIndex for alertmod
  • Stalling at deallocate
  • Apply PivotItemHeader style to PivotItem in UWP
  • Can you use multiple instances of Edge on a Selenium Grid Node?
  • How can I get the maximum number of OpenMP threads that may be created during the whole execution of
  • Having an issue with my TextBox control template
  • How to delete a newline using \\b
  • How to start server for Selenium grid Java Maven setup
  • How to merge two Request in Laravel
  • Allocating a 2D contiguous array within a function
  • It is possible use the same sql azure instance from two different cloud service of two different sub
  • Dynamically load css stylesheet and wait for it to load
  • Can you perform a UNION without a subquery in SQLAlchemy?
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • Disable Enter in editText android
  • How to check if every primary key value is being referenced as foreign key in another table
  • Display Images one by one with next and previous functionality
  • Delete MySQLi record without showing the id in the URL
  • Unanticipated behavior
  • Comma separated Values
  • SQL merge duplicate rows and join values that are different
  • python regex in pyparsing
  • Trying to get generic when generic is not available
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Bitwise OR returns boolean when one of operands is nil
  • sending mail using smtp is too slow
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize