Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dude, there are plenty of examples in the forum and in the showcase. You may also read this thread and download the generic rpc template for smart gwt or look for smart gwt ee/pro.


    Originally posted by paatal
    hi all,
    I'm newbie with smartgwt
    can anybody post small code snippet how to add record to listgrid.

    I have listgrid and bellow it is add record button
    add record button opens new window for filling parameters for record.
    how to add record now ?
    is it correct if i create ListGridRecord class instance and fill its attributes and
    call dataSource.addData(listGridRecord); ?
    if yes it didn't not work i get javascript errors:
    "(TypeError): null has no properties"

    is it correct if new window call addNewMyObject(My obj ...) mehtod
    and after success adding destroy window and fetch data again ?

    what is correct design pattern ???

    ____________________
    Rgards,
    Paata Lominadze
    Magticom LTD.

    Comment


      Hi, all i think that if you use smart gwt + rpc you may want to use json-rpc or just pass json strings that are converted to java objects to the server. Here is what i mean:

      Code:
      String jsonStringCameFromServerRPC = "........";
      final JSONObject obj = (JSONObject) JSONParser.parse(jsonStringCameFromServerRPC);
      final ListGridRecord record = new ListGridRecord(obj.getJavaScriptObject());
      ds.addData(record);
      All you have to do is to declare DataSourceFields with names, the same as the names of your transfer objects.

      And on the server:
      Code:
      final JSON json = new JSON();
      DTO someDTO .....
      json.addConvertor(DTO.class, new JSONPojoConvertor(DTO.class));
      String jsondto = json.toJSON(someDTO));
      //send jsondto string to the grid
      You get automatic transformation without manual copy for every dto.
      This is just a simple example.
      I am using jetty-util.jar for JSONPojoConverter, it supports nested pojos.

      Hope this helps to someone.

      Comment


        Need help with the Server Side sorting on ListGrid using GWT RPC mechanism

        Hi,

        Can you please post sample line of code to invoke the server side sorting in ListGrid Using GWT RPC.

        How to enable the server side sorting on ListGrid?
        on executeFetch, request.getSortBy() always shows null, how to set this value?

        showcase example was not much of help, can somebody please post the client side sorting line of code vs server side sorting line of code

        Thanks for your great support.

        Comment


          Pagination didn't work

          hi all,
          i found examples about list grid and google rpc on forum. it was clear everything.
          but pagination does not work. here is my classes attached ..
          i didn't know what is incorrect here

          In RouterTab.java i have placed list grid.
          RouterDataSource.java is my datasource class.
          other is my service implementation

          problem is what when i draw RouterTab all records are visible not only first 20,
          which i defined by method listGrid.setDataPageSize(20); in RouterTab.java

          help is urgent :(
          Thanks In Advance.

          ____________________
          Regards,
          Paata Lominadze
          Magticom LTD.
          Attached Files

          Comment


            missed file

            sorry i missed my server implementation file.
            GwtRpcDataSource.java and FetchResult.java i took from this forum, if required i can post them.
            Attached Files
            Last edited by paatal; 21 Jul 2009, 21:32.

            Comment


              Well, even if you set 20 records smart gwt will fetch a little more, than 20. If you mean real paging you will not find one, because the paging is done by life grid with grid scrolling.

              Originally posted by paatal
              sorry i missed my server implementation file.
              GwtRpcDataSource.java and FetchResult.java i took from this forum, if required i can post them.

              Comment


                You have to implement the sorting logic on the server if you use rpc, SortBy returns the name of the column for asc or -column name for desc (i think?!?).
                Client sorting is done automatically, by default by sorting all cached records. This can be tricky if you want server sorting you may want to invalidate the cache.

                Originally posted by ynaik
                Hi,

                Can you please post sample line of code to invoke the server side sorting in ListGrid Using GWT RPC.

                How to enable the server side sorting on ListGrid?
                on executeFetch, request.getSortBy() always shows null, how to set this value?

                showcase example was not much of help, can somebody please post the client side sorting line of code vs server side sorting line of code

                Thanks for your great support.

                Comment


                  RE:

                  Thanks mnenchev for your quick reply...
                  yes you're right i want to create real paging grid,
                  is there any other way to achieve this?
                  i don't need life grid with grid scrolling .... i can't found any other grid ....

                  Originally posted by mnenchev
                  Well, even if you set 20 records smart gwt will fetch a little more, than 20. If you mean real paging you will not find one, because the paging is done by life grid with grid scrolling.

                  ___________________
                  Thanks,
                  Paata Lominadze,
                  Magticom LTD.

                  Comment


                    Originally posted by mnenchev
                    You have to implement the sorting logic on the server if you use rpc, SortBy returns the name of the column for asc or -column name for desc (i think?!?).
                    Client sorting is done automatically, by default by sorting all cached records. This can be tricky if you want server sorting you may want to invalidate the cache.
                    Thanks a lot mnenchev for your prompt reply ,

                    Do I have invalidateCache on HeaderClickEvent

                    listGrid.addHeaderClickHandler(new HeaderClickHandler() {

                    public void onHeaderClick(HeaderClickEvent event) {

                    listGrid.invalidateCache();
                    listGrid.setSortField(event.getFieldNum());

                    }
                    });

                    How can i set the Request.getSortBy() value in executeFetch Method ? Please Help

                    Comment


                      I think this is done automatically?!?!
                      Originally posted by ynaik
                      Thanks a lot mnenchev for your prompt reply ,

                      Do I have invalidateCache on HeaderClickEvent

                      listGrid.addHeaderClickHandler(new HeaderClickHandler() {

                      public void onHeaderClick(HeaderClickEvent event) {

                      listGrid.invalidateCache();
                      listGrid.setSortField(event.getFieldNum());

                      }
                      });

                      How can i set the Request.getSortBy() value in executeFetch Method ? Please Help

                      Comment


                        There is no real paging grids, you must develop one. Btw i met somewhere example for smart gwt in some thread. Look for it.
                        Originally posted by paatal
                        Thanks mnenchev for your quick reply...
                        yes you're right i want to create real paging grid,
                        is there any other way to achieve this?
                        i don't need life grid with grid scrolling .... i can't found any other grid ....




                        ___________________
                        Thanks,
                        Paata Lominadze,
                        Magticom LTD.

                        Comment


                          Originally posted by mnenchev
                          I think this is done automatically?!?!
                          Yes , It is suppose to set this value automatically but it is not.

                          1) Any idea how to set sortState on ListGrid ?

                          listGrid.setSortState(?String ) , dunno how to set this input string value

                          which property of listGrid sets the DSRequest.getSortBy() value?

                          when i print the listGrid.getSortState(), i see the following values
                          listGrid.getSortState() = ({
                          fieldName:null,
                          sortDir:false
                          })

                          2) any sample code on server side sorting using simple smartgwt ListGrid with GWT RPC mechanism?

                          3) Can some one guide me on how to achieve server side sorting using GWT RPC ?

                          Thanks in advance

                          Comment


                            Code:
                            //in ds :
                            	final String sortBy = request.getSortBy();
                                     someRPCservice.fetch(sortBy,..........).....
                            ................
                            // in rpc impl fetch
                            	if (sortBy != null) {
                            			
                            				if (sortBy.charAt(0) == '-') {
                            			
                            					descendingSortOrder = true;
                            				} else {
                            					descendingSortOrder = false;
                            				}
                            			}
                            //        sql query using descendingSortOder
                            If you use the code from this thread it must work, check your datasources declarations?!

                            Comment


                              Originally posted by mnenchev
                              Code:
                              //in ds :
                              	final String sortBy = request.getSortBy();
                                       someRPCservice.fetch(sortBy,..........).....
                              ................
                              // in rpc impl fetch
                              	if (sortBy != null) {
                              			
                              				if (sortBy.charAt(0) == '-') {
                              			
                              					descendingSortOrder = true;
                              				} else {
                              					descendingSortOrder = false;
                              				}
                              			}
                              //        sql query using descendingSortOder
                              If you use the code from this thread it must work, check your datasources declarations?!

                              Thanks a ton, For some reason request.getSortBy(); is returning null always , dunno which property of ListGrid triggers this value ?

                              Please let me know if i have to set some special property to get this value, I will check all DS declarations, Thanks again "mnenchev", you are a Great help.

                              Comment


                                Originally posted by ynaik
                                Thanks a ton, For some reason request.getSortBy(); is returning null always , dunno which property of ListGrid triggers this value ?

                                Please let me know if i have to set some special property to get this value, I will check all DS declarations, Thanks again "mnenchev", you are a Great help.

                                I was able to obtain the Request.getSortBy() value after commenting the following line

                                listGrid.setCanSort(false);

                                If I comment it //listGrid.setCanSort(false); ,
                                then I get the column value using Request.getSortBy() & both the client & server side sorting are enabled.

                                When i uncomment it then Request.getSortBy() is always null & unable to do server side sorting.

                                How can i disable client side sorting & retain just the server side sorting ?

                                Thanks in advance.

                                Comment

                                Working...
                                X