Code Monkey home page Code Monkey logo

Comments (4)

danieleteti avatar danieleteti commented on May 28, 2024

Hi, I cannot reproduce the behavior.
Which version are you using?
Can you reproduce the problem with the latest dmvc version?

from delphimvcframework.

drcrck avatar drcrck commented on May 28, 2024

Hi Daniele,
issue is still present, with last version.

   qTmp.SQL.LoadFromFile( filename );
   qTmp.Open ;
   ViewData ['dati'] := qtmp ;
//-> same if    ViewDataset ['dati'] := qtmp ;
   LoadView(['header','body','footer']);
   RenderResponseStream;

It draws header and footer ( simple html tags ) and body without mustache part expanded.
in body , all "{#dati}}" section is empty.

this simple workaround works :

   ViewData ['dati'] := qTmp;
   LoadView(['header']);
   qTmp.First ;    // <--  reset to first;
   LoadView(['body']);
   LoadView(['footer']);

LoadView move the actual record to Eof , so the nexr "loadview" is empty.
take a look in , MVCFramework.View.Renderers.Mustache, method PrepareModels ,

or in this method:

procedure TMVCJsonDataObjectsSerializer.DataSetToJsonArray(const ADataSet: TDataSet; const AJsonArray: TJDOJsonArray;
  const ANameCase: TMVCNameCase; const AIgnoredFields: TMVCIgnoredList;
  const ASerializationCallback: TMVCDataSetFieldSerializationAction);
var
  LJObj: TJDOJsonObject;
  lDataSetFields: TMVCDataSetFields;
begin
  lDataSetFields := GetDataSetFields(ADataSet, AIgnoredFields, ANameCase);
  try
    while not ADataSet.Eof do
    begin
      LJObj := AJsonArray.AddObject;
      DataSetToJsonObject(ADataSet, LJObj, ANameCase, AIgnoredFields, lDataSetFields, ASerializationCallback);
      ADataSet.Next;
    end;
  finally
    lDataSetFields.Free;
  end;
end;

"ADataSet.First" is never call. but here there is a " while not eof" , so i think "ADataSet.First" must be called before while..

from delphimvcframework.

danieleteti avatar danieleteti commented on May 28, 2024

This issue has been fixed, howeer I strongly suggest to switch to functional actions. Check the updated serversideviewmustache sample.

from delphimvcframework.

drcrck avatar drcrck commented on May 28, 2024

Hi Daniele!
i update dmvc just now, but issue is still present.

i change my code in this way , and now it works:

   ViewData ['dati'] := qTmp;
   SetPagesCommonHeaders(['header']) ;
   SetPagesCommonFooters(['footer']);
   Render(Page(['body'] ));

but method "DataSetToJsonArray" maybe have still the "first" problem...

from delphimvcframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.