Announcement

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

    DataSource default value

    hello
    i have dropdown
    final SelectItem ServiceItem = new SelectItem(); ServiceItem.setName("services"); ServiceItem.setWidth(350); ServiceItem.setTitle("მომსახურების სახე"); ServiceItem.setOptionDataSource(DataSource.get("serviceDS")); ServiceItem.setOptionOperationId("getServices"); ServiceItem.setValueField("service_id"); ServiceItem.setDisplayField("service_name"); ServiceItem.setAutoFetchData(true); ServiceItem.setDefaultToFirstOption(true); how can i take default value of ServiceItem? after onChanged i can take value but before onChanged i can not take default value.

    #2
    Use the DataArrived event.

    Comment


      #3
      thank you
      and one more question please
      if data is empty in SelectItem how to hide scroll in it?

      Comment


        #4
        We don't understand your question.

        Comment


          #5
          sorry it wasn't correct question and i found answer on this what i needed

          Comment


            #6
            i want to get data into listGrid
            final ListGrid myGrid =new ListGrid(); DataSource.get("testDS").fetchData(null, new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { myGrid.setData(response.getData()); } });
            <DataSource ID="testDS" tableName="test_table" serverType="sql" qualifyColumnNames="false" dropExtraFields="false"> <fields> <field name="test" type="text" /> <field name="test2" type="text" /> </fields> <operationBindings> <operationBinding operationType="fetch" operationId="getTest"> <selectClause><![CDATA[ t.test,t.test2 ]]> </selectClause> <tableClause><![CDATA[ soo.test_table t ]]> </tableClause> <whereClause><![CDATA[ t.test=$criteria.test ]]> </whereClause> </operationBinding> <!--<operationBinding operationType="fetch" operationId="exportProblematicPhones" serverMethod="testMethod">--> <!--<serverObject lookupStyle="new" className="ge.magticom.testGwtGwt.server.dmi.DMITest" />--> <!--</operationBinding>--> </operationBindings> </DataSource>
            i getting this error
            The type new DSCallback(){} must implement the inherited abstract method DSCallback.execute(DSResponse, Object, DSRequest) what i doing incorrect? and there isn't needed to specify operationId="getTest"?

            Comment


              #7
              Hi irakli81,

              you are using:
              Code:
                      final ListGrid myGrid = new ListGrid();
                      DataSource.get("testDS").fetchData(null, new DSCallback() {
                          public void execute(DSResponse response, Object rawData, DSRequest request) {
                              myGrid.setData(response.getData());
                          }
                      });
              Your error "DSCallback(){} must implement..." is related to importing com.isomorphic.* classes instead of com.smartgwt.* classes, here for DSRequest.

              Use
              Code:
                      myGrid.fetchData(null, null, new DSRequest() {
                          {
                              setOperationId("getTest");
                          }
                      });
              instead.

              Best regards
              Blama

              Comment


                #8
                before
                myGrid.fetchData(null, null, new DSRequest() { { setOperationId("getTest"); } }); i must write myGrid.setDataSource() right? and how about if i want to apply result of dataSource to "label" component?

                Comment


                  #9
                  You only need setDataSource if you are directly getting the data from your datasource.
                  In Blamas example, you set "myGrid.setData(..)" so you don't need "setDataSource()": you already got the data and you are setting it directly.

                  Inside the execute method, you can do whatever you want with your data. Your data is here. "response.getData()" as an array of records.
                  So, for example, for setting the label text:

                  Code:
                  Label myLabel = new Label();
                  DataSource.get("testDS").fetchData(null, new DSCallback() {            
                        public void execute(DSResponse response, Object rawData, DSRequest request) {                
                              label.setTitle(response.getData()[0].getAttribute("myAttribute"));          
                        }      
                  });
                  "myAttribute" is the attribute in your testDS.ds.xml file. So you are setting the title of the label to the attribute "myAttribute" of the first element of your array of records.

                  Comment


                    #10
                    hello
                    final ListGrid grid = new ListGrid();
                    grid.addSelectionUpdatedHandler(new SelectionUpdatedHandler() { @Override public void onSelectionUpdated(SelectionUpdatedEvent selectionUpdatedEvent) { ListGridRecord listGridRecord = grid.getSelectedRecords()[1]; SC.say(listGridRecord.getSingleCellValue()); } }); i'm getting null with getSingleCellValue() can someone write little code to get value from selected row?

                    Comment


                      #11
                      listGridRecord.getAttribute("nameOfYourAttribute")

                      Why aren't you you using getAttribute() ?

                      Comment


                        #12
                        Originally posted by edulid View Post
                        listGridRecord.getAttribute("nameOfYourAttribute")

                        Why aren't you you using getAttribute() ?
                        because i am beginner is smartgwt and i am so busy that i have not enough time to and my learning speed is slow

                        Comment


                          #13
                          thank u very much it's working

                          Comment


                            #14
                            You may want to read the QuickStart guide, it really helps to understand the concepts

                            Comment


                              #15
                              hello all
                              i want to perform some procedure
                              client side
                              Button btn = new Button(); btn.setAutoFit(true); btn.setTitle("Delete"); btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { try { DataSource dataSource = DataSource.get("testDS"); DSRequest dsRequest = new DSRequest(); dsRequest.setOperationId("getTest"); Criteria criteria = new Criteria(); criteria.setAttribute("SERVICE_ID", 200); dataSource.fetchData(null, new DSCallback() { @SuppressWarnings("rawtypes") @Override public void execute(DSResponse response, Object rawData, DSRequest request) { try { // Record record = response.getData()[0]; // String aaaa = record.getAttributeAsString("SIM_CARD_NAME"); } catch (Exception e) { SC.say(e.toString()); } } }, dsRequest); } catch (Exception e) { e.printStackTrace(); SC.say(e.toString()); } } }); server side
                              <DataSource ID="testDS" serverType="sql"> <operationBindings> <operationBinding operationType="fetch" operationId="getTest"> <customSQL> call test_ika(205024) </customSQL> </operationBinding> </operationBindings> </DataSource> procedure is calling twice and then i getting following error : Cannot perform fetch on a PLSQL statement: next please help me why procedure in calling twice or i getting error?

                              Comment

                              Working...
                              X