PDA

View Full Version : [CLOSED] DataBound null on Grid Store



ptrourke
Apr 21, 2014, 8:10 PM
I have a grid with a store. The store is normally loaded by copying items from another grid (and this works perfectly with JavaScript). However, I am writing functionality for users to save a workset with their selections, and another function for loading saved worksets into the grids.

In the latter function (loading saved worksets), I have multiple grids and so multiple List<SomeObject> properties of the workset object. But I am having a problem with the data store behind one of the grids: the "data" attribute is null and the "databound" attribute is null, with a datasource which contains items, after assigning a data source and data binding:

This is a stub of the workset object logic:



//In a class file

public class MyWorksetObject
{
public int MyWorksetObjectID {get; set;}
public DateTime MyWorksetObjectDate {get; set;}
public MyItemList MyWorksetObjectItems {get; set;}
public MyTaskList MyWorksetObjectTasks {get; set;}

public MyWorksetObject() {}
public MyWorksetObject(int myWorksetObjectID)
{
MyWorksetObjectID = myWorksetObjectID;
}

Load()
{
//Lots of things done
}
}
public class MyTaskList : List<MyTask>()
{
public MyTaskList ReturnTestVector()
{
MyTaskList newTestVector = new MyTaskList ();
newTestVector.Add(new MyTask(1, "First Task"));
newTestVector.Add(new MyTask(2, "Second Task"));
newTestVector.Add(new MyTask(3, "Third Task"));
return newTestVector ;
}
}




And this is a stub of the Workset loading logic:




//In code behind of page
[DirectMethod]
public void MyWorkset_Load()
{
int myWorksetObjectID = 1; //Test vector ID
MyWorksetObject myWorkset = new MyWorksetObject(myWorksetObjectID);
myWorkset.Load();

MyGrid.GetStore().DataSource = myWorkset.MyWorksetObjectTasks;
//In the debugger, MyWorksetObjectTasks has a count of 3.

MyGrid.GetStore().DataBind();
//In the debugger, the MyGrid object says the data source has a count of 3,
// but .data is null and .DataBound is null.

MyGrid.DoLayout();
}


Is there something fundamental I'm missing about how to bind this grid store from the code behind? I'm using a pageproxy on the store.

Thanks!

Patrick

Vladimir
Apr 21, 2014, 9:25 PM
DataBind doesn't update Data property, it is separate property is not related with DataBind
Also DataBound is event, i am not sure why do you check it.

Can you explain what exactly do you try to accomplish?

ptrourke
Apr 21, 2014, 9:54 PM
Thanks, Vladimir.

Sorry, that's my misunderstanding on those two properties. As I said, I am trying to bind the loaded object to the grid, and I'm using a DirectMethod.

The idea is that items are copied from one grid to another, via JavaScript. That code is not represented in this thread, but it works fine (in part thanks to help from you, Daniil, and other folks at Ext.NET and on the forums). When the grid is completed, the user can run a report. If the user wants to work on the report in the future, the contents of this grid (and a couple of other grids) can be saved. Later, I want the user to be able to reload previous worksets - there is one large object that has several properties which are of types that inherit from List<> (each is stored in a separate table), and each such object represents the contents of one grid.

What I'm trying to show is that I'm trying to load the contents of one of the properties into one of the grids.

I'm not getting anything in the grid.

There's probably something I'm doing wrong here, but I'm not sure what it is.

I've set AutoDestroy to false, and AutoLoad to false.

Patrick

Vladimir
Apr 22, 2014, 9:45 AM
Sorry, but I still do not understand your issue correctly
You have initial data which you bind to DataSource. Why do not use that data?



I want the user to be able to reload previous worksets

Just set data to DataSource again and call DataBind

What exactly do you expect in the grid after DataBind calling?

ptrourke
Apr 22, 2014, 6:14 PM
Sorry, Vladimir; I think I'm adding too much extraneous detail to my questions.

I've got Ext.NET doing what I want it to do. The problem is that I still haven't figured out why it wasn't working before / is working now.

Is there a significant difference between the
myStore.LoadData(); command and the pairing of
myStore.DataSource = myObject; myStore.DataBind();? Because in my situation, the first works, but the second doesn't.

EDIT:
After talking with a colleague, we decided to stop wasting your time with this until/unless I have a reproducible problem. :-) Please feel free to *CLOSE* this thread for now.

Thanks!